What should I do if SetAsync errors?

Here are the options:

  • Do nothing
  • Retry once
  • Retry thrice
  • Retry until succeed

Do nothing
If I do nothing when SetAsync errors, the player just loses their data. Auto save could minimise the loss of data, but the player will still lose data.

Retry once
This could prevent the loss of data, but what if the retry also fails? The player will still lose data.

Retry thrice
Same as above. The retries could still fail, and the player will still lose data.

Retry until succeed
This seems like a good solution at first (at least to me), however, if the player tries to join another server while the original server is still retrying to save the data, the player in the other server would be getting his old data and if the retries finally succeed, their data in the other server does not update.

You could check if the player previously had their data saved successfully when they join a server, by checking a boolean saved along with their data, which is set to true when the player leaves and their data is saved, and set to false when the player joins the game. So when the player joins, the bool is set to false, and if they leave and the save fails, the bool remains false. So if they try to join another server, the bool will be false, allowing you to tell your player that their data was not saved.

However all of these result in the same thing- the player’s data could still be lost. But that is something that is inevitable.

How would you approach this?

I would save data in autosave intervals, when the player leaves, or when the game closes. Now in 2 or those 3 situations you have no limit to how much time you can use to save, but when the game closes you only have 30 seconds to save all the player’s data.

As long as you save data regularly you shouldn’t need to try and repeat attempts at saving data. But whatever you do I don’t suggest retrying till it saves. If you hit datastore limits you risk having lots of data lost instead of a single player’s data. You could always consider using an offsite website as a fallback server for data that isn’t being saved on ROBLOX’s servers.

1 Like