|
| 07 Aug 2012 08:19 PM |
game.Players.PlayerAdded:connect(function(player) repeat wait() until player.Character and player.PlayerGui player:WaitForDataReady() m = Instance.new("IntValue", player) m.Name = "leaderstats" h = Instance.new("IntValue", m) h.Name = "Stage" n.Value = 1
player.leaderstats.Stage:LoadNumber("Stage")
end)
game.Players.PlayerRemoving:connect(function(REMplayer) REMplayer.leaderstats.Stage:SaveNumber("Stage") end)
help?!?! |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 07 Aug 2012 08:32 PM |
I'm afraid your a bit off.
(player):SaveNumber("name of value",value itself) (player):LoadNumber("name of value")
fixed script:
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() m = Instance.new("IntValue", player) m.Name = "leaderstats" h = Instance.new("IntValue", m) h.Name = "Stage" h.Value=player:LoadNumber("Stage")>1 and player:LoadNumber("Stage")or 1 end) coroutine.resume(coroutine.create(function() game.Players.PlayerRemoving:connect(function(REMplayer) REMplayer:SaveNumber("Stage",REMplayer.leaderstats.Stage.Value) end) end)) |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2012 08:33 PM |
Sorry I'll further explain :SaveNumber, (player):SaveNumber("name of value",Value of the IntValue, otherwise you'd be saving an instance. So this saves the number, not the entire leaderstats) |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2012 08:38 PM |
| Does that script still set the Value to 1 when they're new players? |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Aug 2012 08:40 PM |
| That script doesn't even insert the leaderstats and Stages. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2012 08:44 PM |
Are you saying that because it didn't work right online?
I'll cut out the ternary operator for a nooby inefficient thingamajig if it wasn't working in game..
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() m = Instance.new("IntValue", player) m.Name = "leaderstats" h = Instance.new("IntValue", m) h.Name = "Stage" if player:LoadNumber("Stage")and player:LoadNumber("Stage")>1 then h.Value=player:LoadNumber("Stage") else h.Value=1 end end) coroutine.resume(coroutine.create(function() game.Players.PlayerRemoving:connect(function(REMplayer) REMplayer:SaveNumber("Stage",REMplayer.leaderstats.Stage.Value) end) end)) |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2012 08:46 PM |
| It doesn't work in both offline and online mode. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Aug 2012 08:54 PM |
game:GetService("Players")PlayerAdded:connect(function(p) ypcall(function() p:WaitForDataReady() local m=Instance.new("IntValue",p) m.Name="leaderstats" local h=Instance.new("IntValue",m) h.Name="Stage" h.Value=p:LoadNumber("Stage")>1 and p:LoadNumber("Stage")or 1 end) end) coroutine.resume(coroutine.create(function() game:GetService("Players").PlayerRemoving:connect(function(r) r:SaveNumber("Stage",r:FindFirstChild("leaderstats"):FindFirstChild("Stage").Value) end) end))
All of the scripts I've given you should work, if this still doesn't then... well either you're doing something wrong or I'm more tired than I think. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2012 08:55 PM |
Oops.
game:GetService("Players")PlayerAdded:connect(function(p) ypcall(function() p:WaitForDataReady() local m=Instance.new("IntValue",p) m.Name="leaderstats" local h=Instance.new("IntValue",m) h.Name="Stage" h.Value=p:LoadNumber("Stage")>1 and p:LoadNumber("Stage")or 1 end) end) coroutine.resume(coroutine.create(function() game:GetService("Players").PlayerRemoving:connect(function(r) r:SaveNumber("Stage",r:FindFirstChild("leaderstats"):FindFirstChild("Stage").Value) end) end))
Also, you can't be in offline or play solo or any of those, data persistence strictly works in Play mode only |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Aug 2012 01:04 AM |
2995...
~2.9k posts/20k posts |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2012 01:39 AM |
| It doesn't work.Why?Because You can't save when a player leave.Use another event to trigger it. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2012 01:50 AM |
game:GetService("Players")PlayerAdded:connect(function(p) ypcall(function() p:WaitForDataReady() local m=Instance.new("IntValue",p) m.Name="leaderstats" local h=Instance.new("IntValue",m) h.Name="Stage" h.Value=p:LoadNumber("Stage")>1 and p:LoadNumber("Stage")or 1 end) coroutine.resume(coroutine.create(function() h.Changed:connect(function() p:SaveNumber("Stage",h.Value) end) end)) end) |
|
|
| Report Abuse |
|
|