Is there a way to prevent data loss?

I might just be wondering because whatever I do to prevent it, it doesn’t prevent it at all…

Are there ways to prevent it?

If so, what are they?

I have been experiencing tons of data loss in my game currently…

I just know from my own experience that you have to use a script, not a local script if you are doing a simulator, or the data won’t save. If you have a video of the data loss I would be able to give more, but that is all I have.

P.S: If you change the name of the datastore, you will get a brand new datastore.

I do not know how to prevent data loss, but I am just giving you what could be happening

You would make “attempts” to save, i guess.

Well, you could try using Datastore2 or compressing the data you’re saving, since datastores have a limit to how much they can store. You can also somewhat prevent datastore loss by having a tries system. You should also use pcalls when saving/updating asyncs.

2 Likes

My problem is about GetAsync(), sometimes it don’t load so it overwrites the current data system they have, I’m using UpdateAsync() already btw.

When are you attempting to update / save data? On a set time interval or when certain events are triggered in the code?

Also make sure if you call some sort of function in the UpdateAsync that it does not yield.

Like I said,

This is what I meant:

local Tries = 5
repeat
   local Success, Err = pcall(function()
      DataStore:GetAsync(key)
   end)
   Tries = Tries - 1
   
   wait()
   
   if Err then
      print(Err)
   end
until Success or Tries <= 0

(note: code is untested)

1 Like

hi there! in the project I’m currently working on, I’ve implemented gameanalytics, and with that I’m able to post “design” events to.

if the player data failes to save, I just gather all the data and put it in a table, and then json encode that, and then post it to gameanalytics, and I include the errors with the error event.

edit: Platform Overview - GameAnalytics Documentation

2 Likes

There are two ways to prevent data loss, 1 you use the instance BindToClose() which keeps the server open a little longer so it can save the last person who was in the games data. If it is more serious then you will have to go to Datastore2 which is a more efficient way for saving data and can be a lot easier to use after you learn and understand it for a bit.

BindToClose()

Datastore2

1 Like

How sure about this are you? Are you certain you aren’t just running into GetAsync’s caching behaviour? A lack of implementation details makes it hard to discern what you’re experiencing here.

UpdateAsync doesn’t guarantee data loss prevention, it only gives you the opportunity to attempt to do so. You need to take advantage of this, as well as any other strategies you can, in order to construct a system where data loss is either completely negated or is minimal.

DataStore2 does an excellent job of eradicating data loss by effectively making data steps. Each time there’s an update to your data (flushed, not set), a new step is created with that data. DataStore2 will explore these steps decrementally, starting from your most recent, until valid data is retrieved.

1 Like

There are a lot of really… weird answers here. I’ll summarize.

Everything you would ever need to know in order to make a reliable data saving system can be found in these three links (Assuming you have at least moderate experience scripting)

Intro to Data Stores / Usage / Etc

Error Catching / Limitations

Once you have a good understanding of Data Stores, use this

@Reshiram110 's addition: Details on DataStoreService for Advanced Developers

1 Like

This could also be helpful - Details on DataStoreService for Advanced Developers

1 Like