What causes player’s data to get rolledback when leaving and rejoining
I have a game and the players get tped to universes from a lobby but when going back to old lobbies they rollback
What causes player’s data to get rolledback when leaving and rejoining
I have a game and the players get tped to universes from a lobby but when going back to old lobbies they rollback
The primary reason is caching. Sometimes datastore queries cache on the server they were made in to reduce queries to the database directly which results in out-of-date data being returned to you.
ProfileService does not have caching issues which makes it very good for universe-wide data management because of its use of UpdateAsync, which is always guaranteed to ultimately find you the most up-to-date data saved to a key.
Is there any solutions without using profile service?
Would adding a value that goes up everytime your data saves work, then comparing it to whats returned from update async
You can honestly just use this code to fetch data without it caching:
-- DataStore is your datastore object from DSS:GetDataStore() --
local data
DataStore:UpdateAsync(key_goes_here, function(loaded)
data = loaded
return nil -- Returning nil in updateasync just cancels your update. This shouldn't deplete your Set budget (I think?). --
end)
print("Data has been loaded!")
Then you can use the data variable to use your data.
Disclaimer: I’m not sure if UpdateAsync gives you back nil if your callback function cancels the update so that’s why I don’t just say local data = DataStore:UpdateAsync...