Spectrumz
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 4338 |
|
|
| 30 Jul 2011 02:06 PM |
game.Players.PlayerAdded:connect(function(p) local leaderstats = Instance.new("IntValue", p) leaderstats.Name = "leaderstats" local GP = Instance.new("IntValue", leaderstats) GP.Name = "GP" p:WaitForDataReady() local gold = p:LoadNumber("Gold") GP.Value = gold end)
game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() local stats = player:findFirstChild("leaderstats") if stats then local pieces = stats:findFirstChild("GP") if pieces then player:SaveNumber("Gold", pieces.Value) end end end)
I'm only posting this thread again because I was on vacation for a week and I lost my previous thread. Now, my problem is that this doesn't save/load anything. I even added a brick that when touched will give you some GP. What I did to test this is touch the brick a few times until I had maybe 10 GP, and left. I then went back in and had 0 GP. The output says nothing. Help? |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2011 02:09 PM |
I hope this helps...
game.Players.PlayerAdded:connect(function(p) local leaderstats = Instance.new("IntValue", p) leaderstats.Name = "leaderstats" local GP = Instance.new("IntValue", leaderstats) GP.Name = "GP" p:WaitForDataReady() local gold = p:LoadNumber(p.Name) GP.Value = gold end)
game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() local stats = player:findFirstChild("leaderstats") if stats then local pieces = stats:findFirstChild("GP") if pieces then pieces:SaveNumber(player.Name, pieces.Value) end end end)
|
|
|
| Report Abuse |
|
|
|
| 30 Jul 2011 02:15 PM |
game.Players.PlayerAdded:connect(function(p) p:WaitForDataReady() leaderstats, GP = Instance.new("IntValue", p), Instance.new("IntValue", leaderstats) leaderstats.Name, GP.Name = "leaderstats", "GP" GP.Value = p:LoadNumber("Gold") end)
game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() if player:FindFirstChild("leaderstats") then if stats:FindFirstChild("GP") then player:SaveNumber("Gold", stats:FindFirstChild("GP").Value) end end end)
~ A Signature |
|
|
| Report Abuse |
|
|
Spectrumz
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 4338 |
|
| |
|
|
| 30 Jul 2011 03:36 PM |
| I bet you didn't even try mine >_< |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2011 04:33 PM |
| Use ChildAdded and ChildRemoved, they are never gonna fix the PlayerAdded thing, it does't work the first time because you are already in the server when the script runs or something like that, bu ChildAdded works. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2011 04:37 PM |
@Mitch
That wouldn't work. The IntValue that is tagged as GP would be made "at the same time" as the other one, therfore it would say leaderstats is a nil valure. |
|
|
| Report Abuse |
|
|
Spectrumz
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 4338 |
|
|
| 30 Jul 2011 06:47 PM |
@eXoguti
Uh huh. Then why does my leaderboard actually insert the leaderstats and GP IntValues, and they're visible on the in-game leaderboard? |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2011 06:57 PM |
@Twil, I found that out after I wrote the script, after trying to make efficient stuff it makes it not as efficient
~ A Signature |
|
|
| Report Abuse |
|
|
| |
|