How to print the entire database table?

  1. What do you want to achieve? Keep it simple and clear!
    I was making a ban system and until an idea popped out in my mind that i should add a feature where you can see a list of banned people. And it requires getting the entire database table
  2. What is the issue? Include screenshots / videos if possible!
    I can’t seem to find a way to print the entire database
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking up the devforums and i didn’t find any answer (same for dev hub)

Something like that in a module?

local BanTable = {
    ["Player's name"] = id
return BanTable

That only gets a single user per database, it should return all of the users in the database with their stats

use a for loop to loop through the table?

Do you mean you want to get all the people in a DataStore??

1 Like

Yes, that’s what I am trying to do here.

But how do you get the entire table of it tho?

for _,playerdata in pairs(Table) do

sorry for no format im on mobile

That’s how you print every member of a table, i am asking how to return a database table.

if its for a gui, try creating a remote function that requests from the datastore players “banned” value

then if they are banned then it returns banned players

if its for global you could try messaging service to store banned players tho, for example store a folder in serverstorsge of banned plsyer strings and when you ban you send a messaging service request to add a value to the folder and then it should change across all servers

What you could do is this. You have multiple datastores. One for the bans, and one with the entire table. Then when you ban someone and add them to datastore 1, call datastore2. Datastore 2 will contain a table of all the players, so you can call that table, and then add the new player to that table. Then you can just call the datastore2 to get the entire player.

Datastore1 = --original datastore
Datastore2 = --Other datastore

--when banning do normal thing for Datastore1

--then lets add them to the datastore2

local currentTable = Datastore2:GetAsync("MainDataStore")
table.Insert(currentTable, playerToBan.UserId)
print(currentTable) --prints a list of all based players

So it’s not possible to return every player’s stats using DataStore 1 right?

Sadly it is not possible, but what I said above should work.