Help with admin panel

So im making an open sourced admin panel, and i need help with making a whitelist system and adding admins to the list through the admin panel. if anyone could help me that would be greatly appreciated! :smile:

1 Like

You’ll need a table of Admin UserIds

local admins = {242324234, 29382492, 3247819392, 283492923}

and then you can check to see if the player is an admin when they join

game:GetService("Players").PlayerAdded:Connect(function(plr)
     if table.find(admins, plr.UserId) then
          -- Clone a panel gui and put it in their PlayerGui
          local clone = script.Panel:Clone()
          clone.Parent = plr:WaitForChild("PlayerGui", 5)
     end
end)

You’ll also want to check to make sure the player is an admin every time you receive a command from the client via a remote so that exploiters can’t abuse them

adminRemote.OnServerInvoke = function(plr, ...)
     if table.find(admins, plr.UserId) then
          local args = {...}
          --// run command
     else
          plr:Kick()
     end
end
2 Likes

Im also trying to make it so you can add admins through the panel,

Use DataStores and then add the userid of the target to the admins datastore, and outside of datastores, you can just do what @twinqle said and then do

table.insert(admins, target.UserId)
2 Likes

You could set up an addAdmin event through the remote functoin

local commands = {}
commands.addAdmin = function(args) -- arg1 = PlayerObject
     if not table.find(admins, args[1].UserId) then
          table.insert(admins, args[1].UserId)
          local clone = script.Panel:Clone()
          clone.Parent = args[1]:WaitForChild("PlayerGui", 5)
          return "Successfully made user " .. args[1].UserId .. " an admin"
     else
          return "Player is already an admin"
     end
end

adminRemote.OnServerInvoke = function(plr, ...)
     if table.find(admins, plr.UserId) then
          local args = {...}
          local commandName = args[1]
          local commandArgs = args
          table.remove(commandArgs, 1) -- remove the commandName
          if commands[commandName] then
               return commands[commandName](commandArgs)
          else
               return commandName .. " is not a valid command"
          end    
     else
          plr:Kick()
     end
end
1 Like

Im not trying to make admin commands im trying to make an admin panel but thanks anyways! :smile:

Right, but the server handling would be the same. The only difference would be that you’ll be sending requests to the server from the client on a gui instead of directly getting them from the server via .Chatted

1 Like

@twinqle Could you please tell me how I would do this with a gui? Also I need to know how to get the UserId from the player thats in the textbox. (sorry if this is too much ;-; )

At this point I’d recommend trying to get more accustomed to Lua before trying to create an admin panel, furthermore an open sourced one that people will probably try to learn off of.

If you’re really trying to skip straight to an admin panel, here’s some key factors that you should read up on that you don’t appear to know: