How do I check all players if their userId is the same as the one in the list, and give them specifically a admin panel?

As the title says, How do I check all players if their userId is the same as the one in the list, and give them specifically a admin panel?

Here is my current script:

local Players = game:GetService("Players")
local AdminIds = {1545243842, 809620631} -- 1545243842 is Quif and 809620631 is the Owner


for _, v in pairs(Players:GetPlayers()) do
	if table.find(AdminIds,v.UserId) then
		-- dont know what to put here
	end
end
1 Like

You can just parent the admin panel GUI to each player’s PlayerGui. Or give them a script that enables that gui upon pressing a button.

I didn’t want all users knowing that there was an admin gui

Yeah, just give all of the user IDs the admin gui in their PlayerGui…

Always check the UserId on the Server, not the client, because it will be vulnerable to exploits.

Client-Side code:

-- Create a RemoteEvent
local CheckUserID = Instance.new("RemoteEvent")
CheckUserID.Parent = game.ReplicatedStorage
CheckUserID.Name = CheckUserID

-- Fire the RemoteEvent
CheckUserID:FireServer()

-- Returns true if matches one of the UserId's
CheckUserID.OnClientEvent:Connect(function(trueornot)
    if trueornot == true then
           --Show Admin Panel Here
    end
end)

Server-Side:

local CheckUserID = game.ReplicatedStorage.CheckUserID

CheckUserID.OnServerEvent:Connect(function(plr)
      if plr.UserId == 1545243842 or plr.UserId == 809620631 then
          CheckUserID:FireClient(plr, true)
      else
          CheckUserID:FireClient(plr, false)
      end
end)
1 Like

This code is still vulnerable to exploits because they can just do UI.Visible = true, so you’ll need to create your ui with scripts instead.

I’d recommend not using a For loop for checking all the players because this will run as the server starts.

You may wanna consider trying the following code:

local Players = game:GetService("Players")
local AdminIds = {1545243842, 809620631} -- 1545243842 is Quif and 809620631 is the Owner

Players.PlayerAdded:Connect(function(Player)
	if not table.find(AdminIds, Player.UserId) then return end

	script:FindFirstChild("AdminGui") and script:FindFirstChild("AdminGui"):Clone().Parent = Player:WaitForChild("PlayerGui")
end)

--// Ofcourse put this script inside ServerScriptService and the Gui inside it, And make sure it named "AdminGui".

Hope you found this relevant and helpful! :smile:

1 Like

All the buttons will have a script to check if the player who clicked it is actually one of the admins