generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How Can You Insure Data Persistence?

Previous Thread :: Next Thread 
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
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
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 07:43 PM
Bump.
Report Abuse
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 07:46 PM
Bump
Report Abuse
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 07:53 PM
Bump
Report Abuse
Azureous is not online. 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
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 07:56 PM
There has to be a way. All other games don't lose progress.
Report Abuse
Kevenpowers is not online. Kevenpowers
Joined: 01 Sep 2012
Total Posts: 453
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
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
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
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
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
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 08:11 PM
Hoping CloneTrooper or Crazyman answers. Since I know they can help out.
Report Abuse
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
19 Jan 2014 08:22 PM
Bump :(
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image