|
| 28 Sep 2014 08:36 PM |
I have this script, and I have a variable called "player"
local player = game.Workspace:FindFirstChild(hit.Parent.Name)
But this line here:
local wins = game.Players.player.leaderstats:FindFirstChild("Wins:")
Does not want to use the variable! Why wont it use it? :( Here is the full script:
script.Parent.Touched:connect(function(hit) local player = game.Workspace:FindFirstChild(hit.Parent.Name) if player then local humanoid = player:FindFirstChild("Humanoid") if humanoid then humanoid.WalkSpeed = 16 end local wins = game.Players.player.leaderstats:FindFirstChild("Wins:") print(wins.Name) if wins then wins.Value = wins.Value + 1 print(wins.Value) end end end) |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 08:37 PM |
Also, here is the output:
19:35:21.018 - player is not a valid member of Players 19:35:21.022 - Script 'Workspace.Level 1.End.Script', Line 8 19:35:21.023 - Stack End 19:35:21.023 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
| |
|
whale
|
  |
| Joined: 09 Apr 2008 |
| Total Posts: 1445 |
|
|
| 28 Sep 2014 08:40 PM |
| local wins = game.Players[player].leaderstats..... etc |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 08:42 PM |
Now its this output:
19:42:07.724 - Workspace.Level 1.End.Script:8: bad argument #2 to '?' (string expected, got userdata) 19:42:07.725 - Script 'Workspace.Level 1.End.Script', Line 8 19:42:07.726 - Stack End 19:42:07.727 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
whale
|
  |
| Joined: 09 Apr 2008 |
| Total Posts: 1445 |
|
|
| 28 Sep 2014 08:44 PM |
| local wins = game.Players[tostring(player)].leaderstats..... etc |
|
|
| Report Abuse |
|
|
Rapster2
|
  |
| Joined: 16 Oct 2009 |
| Total Posts: 1865 |
|
|
| 28 Sep 2014 08:45 PM |
| or just do game.Players[player.Name] |
|
|
| Report Abuse |
|
|
| |
|
Cawlonee
|
  |
| Joined: 03 Mar 2014 |
| Total Posts: 2687 |
|
|
| 28 Sep 2014 08:46 PM |
local character = game.Workspace:FindFirstChild(hit.Parent.Name) local player = game.Players:FindFirstChild(hit.Parent.Name)
local wins = game.Players.player.leaderstats:FindFirstChild("Wins:")
so
script.Parent.Touched:connect(function(hit) local character = game.Workspace:FindFirstChild(hit.Parent.Name) if character then local humanoid = character:FindFirstChild("Humanoid") if Humanoid then Humanoid.WalkSpeed = 16 end local wins = player.leaderstats:FindFirstChild("Wins:") print(wins.Name) if wins then wins.Value = wins.Value + 1 print(wins.Value) end end end) |
|
|
| Report Abuse |
|
|