Data Loss Issues

So I have a game with a decent amount of players, but recently I have been having issues with people losing their data, all of it.

I’ve tried lowering the amount of times it auto saves, and thought about profile service but I don’t know how I would transfer every player’s data into that.

I would appreciate any potential solutions if anybody has any.

(my datastore system uses a folder instance with data values inside of it and reads the folder, then saves it to the datastore, it then loads the data into the folder)

2 Likes

Can I see how you organize and structure your value instances to save for the datastore?

sure:

image
image

I have a feeling the titles part might have something to do with it since its a ton of values, how it works is the parent value true if you own it, and the child value is true if you have it equipped.

Maybe it’s because the server crashes while auto saving player data. In this case you should use game:BindToClose and save all player data in a function, something similar to this:
image

I would also recommend you use :UpdateAsync() instead of :SetAsync().

Hope this helps!

Thank you, ill try this and see if people still report data loss

Hey Nooblite!

This issue occurs because

When player joins the game their data takes about a second to load.
Imagine a case where player leaves without their data fully loading in.
Provided code does not check if the player data loaded in yet, so it’s saving empty data when player joins and leaves instantly.

You can use your DataLoaded BoolValue & save if so.

Here is a flowchart on whats going on.
I made this in half an hour.

If you do end up transferring to profile service, all you have to do is make a script that gets the data from the old datastore, and then put it into the profile service one

First: Don’t run SetAsync in a loop, roblox does it automatically for you and you simply can create another error

Second: Use update async, as it allows you to update data rather than overwrite it, you can compare oldData id and current data id, you must create number that grows every time you save, if they are equal then save, otherwise return nil

Third: Autosave every 5 minute with UpdateAsync will be more effective

Fourth: Detect if game is closing by BindToClose function, then tell player removing event to not run, and save every player’s data by using for loop and your function

Those steps make data loss a lot less common, you can’t prevent data loss fully sadly, but we can reduce it to minimum to provide better experience