Admin datastore problem

I have admin system, saving all admin ids to datastore, but i have problem, how to read all lines in datastore to check if there is someone that i dont whant to be in (for example if i stupidly make some backdoors and i will see it after 5 days), also, can i filter it by its value?
edit: i have ids there so it will be also good to automaticly convert them to username

3 Likes

If you are not going to be changing admins often, then might I just suggest coding the admin user IDs into the script. It is less convient, but if you are worried about backdoors that is a safe option.

1 Like

a)I plan to have big admin platform
b)I have moderators… in the database too (also minimal ranks are there so it will be 1. big and 2.often changing)
c) I have promotion system, that cant work in script
so i need to make that i will tybe admin comand viewall and i will get complete list of players

1 Like

You can store a table into the datastore (it will get serialized as JSON). This way you can store the array of admins into the datastore and retrieve it with no problem. The value limit for a single datastore entry is 260,000 characters (https://developer.roblox.com/en-us/articles/Datastore-Errors), which should be more than enough.

1 Like

So I can’t get all lines of datastore, but I must save array into it?
Edit: for me it will be best, if I can use path definition like when i am selecting item in workspace except of :getAsync()

1 Like

I would recommend then using a For Do loop

Example

For i,v in pairs(Datastore:GetChildern()) do
 print(v) --This will print each of the IDs
end

Attach that to a command and you can use it to check who the admins are
this does not work

1 Like

I don’t think Roblox allows you to iterate through keys in their datastores, so yes, you would need to do something like that. You can store a local copy of the admins when the game starts so you don’t need to call the datastore every time you need the list of admins.

2 Likes

No i havent PC here so i will test it tomorrow (i am gtm +1)

No, that don’t work, I also have idea to use ordered datastore, but I have no idea how to use it (I read wiki, but I did not learn anything from it (I was just confused))

Would be nice to include any scripts you tried to do.

I have no idea, how to do it, so I am completely at start line, only think I have, that is needed it for this, it that I have datastore “pravomoce” (from my language) and in that I store admin id as key and his admin rank as value

I would suggest you storing the admins userids other than the names.

Run this one time (ONLY)

local DS = game:GetService("DataStoreService") local Database = DS:GetDataStore("Admins")

Database:SetAsync("Admins", {})

Then put this in the script to check the admins.

local DS = game:GetService("DataStoreService") local Database = DS:GetDataStore("Admins")

local admins = Database:GetAsync("Admins")

for i,v in pairs(admins) do
      print(v) -- Prints admins userid.
end

To add admins make a way, and add this code:

 local DS = game:GetService("DataStoreService") local Database = DS:GetDataStore("Admins")

Database:UpdateAsync("Admins", function(oldTable)
oldTable.insert(ADMIN USERID)
return oldTable
end)

You must have a small knowledge of scripting before using those things.

Ok so there is no command to get all lines in database? And if I use ordered datastore, is there any way?

I would suggest you to learn basics of coding before attempting to do something like this, no body is gonna do everything that you want for you.

I know scripting, but I am beginner at datastore, because only thing I did is to write money when someone leave and read money when someone join, but I made my first script when I was 7 years old.

Then do basic datastore, not complex.

But how to see all results of datastore

@phSalami already provided you the code. I suggest you take some more time trying to understand it.
We are suggesting you use a single entry in the datastore to store an array of all admins, rather than use multiple entries. This is because you cannot iterate through all entries in a datastore.

I understand it, but I was asking if there is way to export all lines. Now I understand that no
Thx

This is bad advice. Updates for your game should be only when you absolutely need to change something important, not just remove a number from a table. Especially if you have to shut down the game to keep things consistent between versions, it would confuse players when they see nothing has changed.

1 Like