|
| 30 May 2013 09:31 PM |
Im making a dodgeball tool, and I want it so that you gain 1 "point" when you hit someone, please help. This is what I have that just wont work.
function onTouched(player) local plaay = player.Parent local humanoid = plaay:findFirstChild("Humanoid") local stats = game.Players:findFirstChild(player).leaderstats if stats ~= nil and plaay ~= nil then local Points = stats:findFirstChild("Points") Points.Value = Points.Value + 1 end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:32 PM |
Output?
http://www.roblox.com/My/Groups.aspx?gid=66545 |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 May 2013 09:33 PM |
| All it says is that "local stats = game.Players:findFirstChild(player).leaderstats" is an "attempt to index a nil value" |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:34 PM |
| That means it doesn't exist. Maybe reorder your code. |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:35 PM |
Either stats or leaderstats does not exist.
http://www.roblox.com/My/Groups.aspx?gid=66545 |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:36 PM |
| Well, it works as a button but as a tool, it wont work. |
|
|
| Report Abuse |
|
|
| |
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 30 May 2013 09:39 PM |
local stats = game.Players:FindFirstChild(plaay.Name):FindFirstChild("leaderstats")
- You tried using the 'FindFirstChild()' method, with an object as an argument (part). It takes a string.
|
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:44 PM |
Hopper Bins wont work
Thanks @above |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:48 PM |
| Actually, it didnt even work. |
|
|
| Report Abuse |
|
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 30 May 2013 09:53 PM |
| And it'd be nice if you posted any change in output. That was just something that was quite an obvious fault... |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 09:56 PM |
| Ive already said "attempt to index a nil value" |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 10:07 PM |
function onTouched(player) local plaay = player.Parent local humanoid = plaay:findFirstChild("Humanoid") if not humanoid then return end--maybe check if it's a character? local stats = game.Players:findFirstChild(plaay.Name).leaderstats if stats ~= nil and plaay ~= nil then local Points = stats:findFirstChild("Points") Points.Value = Points.Value + 1 end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|