how do i make an admin list to an admin panel? i do not know any type of scripting so i need some help at scripting for admin list.
Hmmmm well you could put player names in a script and if there name is equal to Example: SpiderGuy3
then the gui is visible for them.
local adminIDs = { -- put userid here
0 = true,
1 = true,
}
local function IsAdmin(id)
for _,v in pairs(adminIDs) do
if v == id then
return true
end
end
end
game.Players.PlayerAdded:Connect(function(player)
if IsAdmin(player.UserId) then
print(player.Name, 'Is an admin!')
end
end)
Hmmmmmm, can the gui be opened by player id?
Just check if the player in the array is present in the game, then clone the GUI to them, then every time they fire a command run the check. The script provided above already is utilizing playerID.
The dictionary is totally avoidable and a regular array will do.
Instead of {0 = true} you can just have {0,1,3162361,1239816273}
And then you don’t need to loop through it either
local adminIDs = {0,1,40,547}
game.Players.PlayerAdded:Connect(function(player)
if table.find(adminIDs, player.UserId) then
print(player.Name, 'Is an admin!')
end
end)
Alternatively, if you need to use a dictionary, for some reason. You don’t need to loop through it, just search for a value, if it exists, then go ahead
local adminIDs = { -- put userid here
0 = true,
1 = true,
}
local function IsAdmin(id)
if adminIDs[id] ~= nil then -- in case the value is set to false and you still want to count it, nil checks if it doesn't exist
return true
end
end
game.Players.PlayerAdded:Connect(function(player)
if IsAdmin(player.UserId) then
print(player.Name, 'Is an admin!')
end
end)
3 Likes