DataStore Losing Data due to players Server Hopping fix?

So, players in my game are losing data due to them server hopping back and forth between servers.

I have a while loop for each player that saves their data every 120 seconds.
The data also saves when the player leaves the game, and saves when they purchase something.
But, when they go to an older server they were in before, their Data is outdated and the new data gets overwritten.

How can I fix this?

Keep in mind that to save data I am using UpdateAsync, I rarely use SetAsync to save Data

Is the new data saved and then overridden after hopping onto another server? if so then
You could try storing a age value that keeps the age of the data, the age goes up by 1 everytime you save and you never save any data with a lower age value then the current age

Edit: re-read what you wrote, is the data not being nullified when the player leaves? you dont want to save the data on the old server over the new data

Why are you saving data like that? You should always save the player’s data when they leave, in addition to periodic saves.

Edit: Skipped over important details.

I am doing that tho

It saves the data when they leave, so on the new server it loads it perfectly and saves fine, but when they return to the original server, the old data somehow appears instead of the new data. What could cause this?

Possibly caching? i wouldnt think so as the caching is only 4 seconds but it could be a possibility?
also make sure to completely wipe the data off of the old server so you dont mix up the data

Are you loading the correct data? I know sometimes people like to keep previous save files in case an update breaks their game, so they can rollback player’s data.

Yea I am, there’s only one dataset in my game.

In the game mode round, I forgot to set the in-game stats to nil.

The lobby was working fine, I never looked at the game itself!

1 Like