Retrieve all data from a DataStore

Me and my friend are making a game. We are going to make a in-game leaderboard with the TopStats. But I don’t know how to get all data from the DataStore to compare it with each other using a loop.

2 Likes

The best solution for this is using an OrderedDataStore. OrderedDataStore’s give you the opportunity to get an ordered list of users in the datastore. Usage is very similar to standard DataStores, you can do SetAsync(id, integer). To retrieve the data, you would use GetSortedAsync().

The article I posted contains documentation and an example on how to use them.

6 Likes

If you’d like to know how to make a global leaderboard, I have a tutorial on it here:

In essence, you can’t use DataStores as you need all the data, which would throttle requests easily. Instead, you can use OrderedDataStores, which allow you to sort a bunch of numerical values.

2 Likes

Thank you for your help. It’s much appreciated

Thank you so so much, I was worrying I wouldn’t be able to do what I was trying to accomplish. Have a good night/day