Change everyone's data efficiently (Even if they're offline)

I want to create a rollback system, however, the current problem is that i don’t know how to change everyone’s data efficiently (or just get the data), even if they’re offline. I have tried to get every key with a pairs statement, but i don’t think that’s the correct way to do it, i would like an answer for this, thanks for reading.

Keep in mind that you need to use :GetOrderedDataStore() instead of :GetDataStore() when using it.

Could you explain it, please? I mean, why should I use GetOrderedDataStore? Thanks for reading.

GetOrderedDataStore returns a list that has all of the datas (But it is ordered), then all you would need to do is iterate through it.

Could this be an issue with datastores that has 1k+ keys, for example?

I mean, if you are saving the table in data store (Not each key) then it aint a problem.

In the list you will probably have the User ID of the person as the key so you can do game.Players:GetNameFromUserIDAsync(userID)

Since its a list then you will have all of them.

1 Like

Not really, as long as you’re not looping it constantly every frame or something.
Datastores only use really simplistic data like numbers and basic values, so even if there’s thousands of keys, there usually isn’t going to be enough content in there to cause substantial lag.

Thanks for helping! But i got a question. If i change every key’s data, it would reach the DataStore limits?

It wouldn’t as long as your not doing it all at once.