Getting all players' data from DataStore

How would I get all players’ data from a dataStore? I’m making a ban module with a function called “BanService:GetBannedUsers()” and using “table.insert” to insert to the table with all banned players that will be returned.

What have I tried so far? I’ve looked through many devforum posts trying to find a solution, however, all of the ones I found were to do with a global leaderboard, I simply want to get all the banned players.

Think it’s not possible to just make a call to every single key there exists. You should try to store the keys that refer to the banned users rather than tagging users banned.

I wonder, does for i,v in pairs work for :getdatastore

Perhaps, but you should try this instead:
https://developer.roblox.com/en-us/api-reference/function/DataStore/ListKeysAsync

Then use a separate DataStore that stores anything(a boolean, doesn’t matter if it’s true or false) and then use ListKeysAsync to find every listed player on that store. Keys should probably be the UserId as far as I’m concerned.

2 Likes

So this basically is the solution to his answer :open_mouth:

I believe that should work, thank you :slight_smile: