|
| 19 Jan 2014 07:40 PM |
I made a save and load script. It waits for the player's data. Then loads. But sometimes randomly it doesn't load the saves. I don't know why it doesn't load sometimes. I saved the data to the place ID but it still won't work. I also have a prefix to help. It works many times but at some point it doesn't load the data. Therefor when the player leaves it saves the new data wich causes him to start over. Here's the code:
dp_prefix = "SaveStats"
game.Players.PlayerRemoving:connect(function(player) player:SaveNumber(dp_prefix .. "Experience"..tostring(game.PlaceId),player.PlayerStats.PlayerXP.Value) player:SaveInstance(dp_prefix .. "Stats"..tostring(game.PlaceId), player.OStats) end)
game.Players.PlayerAdded:connect(function(player) wait(0.050) player:WaitForDataReady() XP = player:LoadNumber(dp_prefix .. "Experience"..tostring(game.PlaceId)) stats = player:LoadInstance(dp_prefix .. "Stats"..tostring(game.PlaceId)) end)
stats.Parent = player player.PlayerStats.PlayerXP.Value = XP
--------------------
Like I said it works most of the time. But at some point it stops working. I tried Pcall but it caused the script to not save at all. Does anyone know any other way to insure the stats saving and if possible post a code that I could use that is more efficient? Thanks!
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
Azureous
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25287 |
|
|
| 19 Jan 2014 07:53 PM |
| pcall is mainly for syntactical errors so that the entire script doesn't break if I remember correctly.... there's not really a better way to ensure it |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:56 PM |
| There has to be a way. All other games don't lose progress. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:56 PM |
Dude take this script its a auto-save script it saves leaderstats. http://www.roblox.com/FRIEND-ME-Data-Persistence-LEADERBOARD-STATS-ONLY-item?id=112914964 |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:57 PM |
| Is it a LocalScript? The wiki said it was optimal for it to be a normal Script... Other than that I can't really help much. :P |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 08:01 PM |
| It's not a local script. It's in the workspace. That scriptyou suggested with the link is not helpful at all. It's to basic and risky. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 08:11 PM |
| Hoping CloneTrooper or Crazyman answers. Since I know they can help out. |
|
|
| Report Abuse |
|
|
| |
|