I wonder if i can save data frequently to datastore, is this even possible with datastore2?
My solution so far :
- Save the data every 5 seconds/more
- Save the data with PlayerRemoving event
I’ll appreciate every response
I wonder if i can save data frequently to datastore, is this even possible with datastore2?
My solution so far :
I’ll appreciate every response
I personally with DataStore2 is save upon the player leaving.
From Gotchas - DataStore2
The normal way of doing data stores is to keep a cache somewhere of a player’s data (such as in a folder or using leaderstats), then saving when the player leaves. It is wrong, however, to use DataStore2 this way . DataStore2 is built to be used whenever your data actually changes. You shouldn’t invoke DataStore2 in PlayerRemoving at all . Don’t worry,
:Set
will never error or do API calls, it’s all cached. DataStore2 will save the player’s data before they leave.
In short, don’t manually do anything on PlayerRemoving, because DataStore2 is already automatically doing it for you.
ok, but is it safe to save data like 10 increments per second?
Do you mean change the cached data by calling Set, or pushing the cached data to DataStores by calling Save? The former is totally fine, that’s one of the great appeals of DataStore2. The former will not work. You’ll hit rate limits real fast.
ahh i see, so basically :Increment() will cache my data and not saving it to roblox before :Save() is called right?
yeah increment() and set() cache data, datastore2 saves by itself automatically you just need to update its cache
ohhh ok thankyou for your reply!