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 » Scripters
Home Search
 

Re: Preventing save data from being erased?

Previous Thread :: Next Thread 
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
17 Apr 2012 02:51 PM
Is there any effective way of doing this? I hate it when people spend anywhere from hours to years of their own time playing one of my games, and all of their data suddenly gets erased by Roblox. This definitely isn't because it's going over the limit of 45 KB, because sometimes it's sometimes just a simple inventory with 40 IntValues inside. It happens most often when a game shuts down or a player disconnects. I'm creating a huge game, and I don't want everyone losing everything all the time.

So is there any good way of preventing this from happening?
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
17 Apr 2012 03:01 PM
Save every few minutes. When a game shutdowns or a player disconnects, it doesn't have time to save.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
17 Apr 2012 03:05 PM
It's ERASED, not rollbacked.
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
17 Apr 2012 03:11 PM
I bet you're saving the values to nil.

Make sure to check to see if the value exists before saving them.

Also, if that's not the case, sometimes logging in, then logging out will fix it.
Report Abuse
Techboy6601 is not online. Techboy6601
Joined: 29 Jun 2009
Total Posts: 4914
17 Apr 2012 03:21 PM

According to my experiences DP is saved only when you exit the game - although I could be wrong.

I guess it's so people don't while true do DP saves and overload the server.


~Techboy6601: The IDE guy~
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Apr 2012 03:23 PM
@Tech: In ur experience there probably weren't things like save buttons or loops saving.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
17 Apr 2012 03:29 PM
Quenty, I know I'm not saving the data to nil. It's all completely visible to whoever it belongs to. If there was just one thing being saved to nil, then that would obviously be the case. But it's erasing everything that player has in the game, not just one save key.
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
17 Apr 2012 05:01 PM
What I think is happening, is that it's like:

Player = nil

But you called it to save, right before, so it's trying to save the value of a nil object in the player. :/
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
17 Apr 2012 05:05 PM
I'm personally not finding it very hard to believe that Roblox is nuking your save data. I'm afraid there's nothing you can do about it, though.
Report Abuse
shortPinman is not online. shortPinman
Joined: 02 Apr 2010
Total Posts: 16303
17 Apr 2012 09:04 PM
[ Content Deleted ]
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 10:50 AM
@Quenty
The player clicks save, they leave, come back, and everything they had is erased.

@NVI
It happens all the time. So far, I see no pattern in when it happens, besides when it exceeds the 45 KB limit, which I have prevented.

@Short
What did you do to prevent it from erasing data?
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
19 Apr 2012 11:30 AM
Roblox never erases data. =/
It's much more likely that you're just not saving correctly.


I have found that if you shutdown a server, Players.playerRemoved (or whatever) doesn't fire, so don't stick your persistence code in there. This probably isn't your problem though.



Just make a really really simple test place and try it out. A lot of the time something looks at fault when really it's the complexities of your game to blame.

onPlayerAdded(player)
player:WaitForDataReady()
if player:LoadString("test") == "howdy" then
Instance.new("Message",player).Text = "WORK"
end
player:SaveString("test","howdy")
end

game.Players.PlayerAdded:connect(onPlayerAdded)
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
19 Apr 2012 11:42 AM
It's highly likely that it's your fault. It's not very hard to write code that in an edge case accidentally deletes all of your data. For example, if you accidentally write a whole bunch of data to the thing which well exceeds the cost all at once, that it another possibility for how stuff could be getting deleted.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 02:54 PM
Then I'm not seeing what I'm doing wrong. I can see everything I'm saving. It's just a few IntValues stored in a player's inventory. I can see my inventory. I can see how much of which item is being stored in it. The game saves every 30 seconds. I played it several times before and it worked every time, then it was just one time that everything had been erased when I came back. There was not a huge amount of data being saved, it was all just about the same. I wasn't trying to save 2 million values, I was saving less than 20.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 02:56 PM
    while wait(30) do
        for _, v in ipairs(game.Players:GetPlayers()) do
            Delay(0, function()
                if v:findFirstChild("System") and v:findFirstChild("Inventory") then
                    v:WaitForDataReady()
                    v:SaveInstance("Inv", v.Inventory)
                end
            end)
        end
    end

Am I doing something wrong here?
Report Abuse
shortPinman is not online. shortPinman
Joined: 02 Apr 2010
Total Posts: 16303
19 Apr 2012 03:24 PM
[ Content Deleted ]
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
19 Apr 2012 09:26 PM
You only need to :waitForDataReady() once per player. By doing it again, you might be causing an infinite loop so it never reaches the saving code.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 09:28 PM
If you only need to do it once per player, then why would you ever need to do it at all? Just game.Players.PlayerAdded:connect(function(p) p:WaitForDataReady() end) and then you can save whenever you want? That's weird.
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
19 Apr 2012 09:56 PM
What it does it halt your script until it's ready.

It's basically: repeat wait() until player.DataReady

It only exists to help you out, it's not something which turns on persistence.
Report Abuse
myr8 is not online. myr8
Joined: 10 Apr 2012
Total Posts: 100
19 Apr 2012 10:02 PM
[ Content Deleted ]
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 10:27 PM
How would I cause an infinite loop if it's just going to check for the same thing?
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
19 Apr 2012 10:31 PM
I'm assuming it's the problem because it's the only thing out of the ordinary in your script that could cause it to stop working. I don't really know for sure, but fix it up and see if it works.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 10:43 PM
I'm still unsure on what is supposed to happen, or what isn't being done right. As far as I know, I'm supposed to put player:WaitForDataReady() the instant before I save or load data.
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
19 Apr 2012 10:52 PM
Nope. Basically, once it's ready, it's ready for the rest of the game. WaitForDataReady just waits for that initial loading to finish at the start of the game. It's good to put it with other waiting things at the start of the script, like waiting for the character to spawn and such.
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Apr 2012 11:01 PM
Oh, okay. So nobody has complained about this happening in any other games before?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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