|
| 17 Sep 2011 07:01 PM |
Anyone know why this doesn't work? No output, sorry.
game.Players.PlayerRemoving:connect(function(oldP) oldP:WaitForDataReady() ls = oldP:findFirstChild("leaderstats") if ls then mon = ls:findFirstChild("Money") if mon then oldP:SaveNumber("Money", mon.Value) end end end)
game.Players.PlayerAdded:connect(function(newP) newP:WaitForDataReady() local leaderstats = Instance.new("Model", newP) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Money" while true do wait(3) money.Value = money.Value + 10 end SavedMoney = newP:LoadNumber("Money") if SavedMoney.Value == 0 then SavedMoney.Value = 1 end mon.Value = SavedLevel end) |
|
|
| Report Abuse |
|
|
| |
|
GoldenUrg
|
  |
| Joined: 23 Aug 2009 |
| Total Posts: 6428 |
|
|
| 17 Sep 2011 07:58 PM |
Doing a wait in PlayerRemoving event is dangerous, the player may be gone before the wait finishes.
You should add a method to save the data manually, so you can test whether it's save or load that is failing. |
|
|
| Report Abuse |
|
|
jjjakey
|
  |
| Joined: 15 Sep 2008 |
| Total Posts: 13014 |
|
|
| 17 Sep 2011 08:11 PM |
Actually, PlayerRemoving is better for Data Persistence. This is because the data isn't sent to the Roblox server until the player leaves.
Anyways, you'll want to remove the 'WaitForDataReady()' in the PlayerRemoving function. You want to capture the data your going to save as soon as possible. |
|
|
| Report Abuse |
|
|
| |
|
jjjakey
|
  |
| Joined: 15 Sep 2008 |
| Total Posts: 13014 |
|
|
| 17 Sep 2011 08:26 PM |
If your STILL having troubles, try to make a string of whatever your going to save. That way, you got your data and the player can leave.
game.Players.PlayerRemoved:connect(function(Player) Number = Player.leaderstats.Number.Value
Then you can save the number from there. |
|
|
| Report Abuse |
|
|