Executing functions in order

Let’s say, I am saving a player’s data with DataStore:UpdateAsync() when they leave the game, and let’s say it fails to save, so it retries for like 30 more seconds, sending more UpdateAsync calls until the save is successful.

Before the save request even finishes successfully, the player leaves and manages to join the same server again, triggering the server to load their data. However, because the save request hasn’t finished, the server loads the player’s old data. So now, when the player continues to play, they’ll be overwriting their new data (the data that the save request took some time to complete) when they leave the game again or whenever a save occurs.

What kind of solutions r there to go about this? How do u ensure that the server accesses player data only after previous datastore requests are finished?

I’m not looking for datastore module suggestions if that’s what you were gonna comment :]

I got these modules from over a year ago that may help you:

I’m confused on what the description of the module means
“This Module helps to avoid black-listing from HTTP rate-limits by distributing the time functions are being called.”

How does it help my problem?

A common one, which I believe is used in the ProfileService wrapper for Datastore Service, is to have another datastore that you temporarily save a value to when the player is loading, then delete the saved value when they leave and everything is finished. Then, when they join a new server, if the value that marks if they are in game exists, then the player can just be kicked until it marks them as no longer in a server (or until X time passes).

Big block of text so sorry if it doesn’t make sense.

So, it’s sort of similar to session locking?

Yeah