|
| 27 Nov 2014 10:06 AM |
I am trying to add "candy canes" to the players leaderstats at the end of each round but my script wont work. Do you know what is wrong?
for i,v in pairs(game.Players:GetChildren()) i:FindFirstChild("Candy Canes").Value = i:FindFirstChild("Candy Canes").Value+100 end)
haydebug2003 |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 Nov 2014 10:07 AM |
v, not i i is the key and is actually a number |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 10:07 AM |
| Use V, not I. I is a number. V is a value. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 10:08 AM |
The V still had a red line under it.
haydebug2003 |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 10:09 AM |
Nvm forgot to add do WOOPS
haydebug2003 |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
| |
|
|
| 27 Nov 2014 10:09 AM |
Output reads 09:09:30.621 - ServerScriptService.Script:31: attempt to index a nil value
haydebug2003 |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 10:13 AM |
You are using FindFirstChild twice, and not even using it to check if the child exists.
Use it only once, and then don't use it again. When you use it the first time, check if it is nil before proceeding. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 10:15 AM |
I got it. If you want the script here it is. for i,v in pairs(game.Players:GetChildren()) do v.leaderstats["CandyCanes"].Value = v.leaderstats["CandyCanes"].Value+100 end
haydebug2003 |
|
|
| Report Abuse |
|
|