Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 02:57 PM |
I am writing a simple script that teleports users to the home base (0,0,0), then gives them some points.
Here is the leaderboard:
Here is the button code:
[code] function onTouched(hit) hit.Parent.Torso.CFrame = Vector3.new(0,0,0) hit.leaderstats.Points = hit.leaderstats.Points + 10 end script.Parent.Touched:connect(onTouched) [/code]
[code] game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats' money.Name = "Points" --this is the name you want the leader-stat to be when it shows up in-game. money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) end) [/code]
|
|
|
| Report Abuse |
|
|
Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 02:59 PM |
| on the points side, I have seem to got the .Value tag thinger. But tele does not work? |
|
|
| Report Abuse |
|
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
|
| 25 Mar 2014 03:06 PM |
its not vector3 its CFrame.new
plus if you move the toro the character will die |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|
Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 03:07 PM |
Points still do not work :(
Then how do I teleport the user? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2014 03:13 PM |
if hit.Parent then player=game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.Character:MoveTo(0,0,0) end end |
|
|
| Report Abuse |
|
|
Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 03:23 PM |
I have:
function onTouched(hit) hit.leaderstats.Points.Value = hit.leaderstats.Points.Value + 10 if hit.Parent then player=game.Players:GetPlayerFromCharacter(hit.Parent) if player then player.Character:MoveTo(0,0,0) end end end script.Parent.Touched:connect(onTouched)
And it still does not work? Any ideas? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 25 Mar 2014 03:28 PM |
leaderstats should be a property of player, not character.
Just move the part where you defined player up.
function onTouched(hit) if hit.Parent:FindFirstChild ('Humanoid') then -- this means it's a character player=game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Points.Value = player.leaderstats.Points.Value + 10 hit.Parent:MoveTo(0,0,0) end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 03:45 PM |
| Gives me 10 points, but if I step on it again, it doesn't give me another 10 points. Also it doesn't teleport. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 25 Mar 2014 03:51 PM |
script.Parent.Touched:connect(function(Hit) Player = game.Players:GetPlayerFromCharacter(Hit.Parent) if Player then Player.Character:MoveTo(0,0,0) Player.leaderstats.Points.Value = Player.leaderstats.Points.Value +10 end end) |
|
|
| Report Abuse |
|
|
Alopek
|
  |
| Joined: 05 Jan 2014 |
| Total Posts: 32 |
|
|
| 25 Mar 2014 05:55 PM |
| This does not work whatsoever. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Mar 2014 05:57 PM |
| hit.Parent.Torso.CFrame = CFrame.new(0,0,0) |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2014 06:04 PM |
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then plr = game.Players:GetPlayerFromCharacter(hit.Parent) hit.Parent:MoveTo(0,0,0) plr.leaderstats.Points.Value = hit.leaderstats.Points.Value + 10 end end)
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats' money.Name = "Points" --this is the name you want the leader-stat to be when it shows up in-game. money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) end) |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2014 06:05 PM |
| Not only should that fix the tele problem, but it should fix a point error |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 25 Mar 2014 06:09 PM |
Didnt read any of it but...
:MoveTo(Vector3.new(0,0,0)) |
|
|
| Report Abuse |
|
|