Datastore not Saving most of the time

So I have a datastore setup that saves only 3 values,
but… MOST of the time when I leave the game, it only prints(“a”) and so the data won’t save.
I heard this was a common problem and I want to know if any of you guys know how to fix this.

code:

print("a")
self._store:SetAsync(key, data)
print("b")
1 Like

Bump! This is a problem I recently started facing, the GetAsync() method works correctly, but on player leaving using method SetAsync(), it doesn’t save at all. Tested both in studio and in game.
And yes, I’ve used pcalls to return values which don’t return anything most of the time.

You want to use pcall() so then if it fails you can detect it and do something about it but doing this approach with just printing isn’t as efficient

That’s just part of the code, of course im using pcall lol

it happens in both studio and in game :confused:

1- You didn’t show a good amount of code so i can respond or help you in any case.
2- How about you wrap it on a pcall and repeat that set async request until it saves or gets to a limit, Also use BindToClose Event.