Trying to make a admin script but the table list doesn’t seem to work as it gives admin to everyone.
local adminsList = {
219993365,
472072511
}
game.Players.PlayerAdded:Connect(function(player)
local adminChecker = Instance.new("BoolValue")
adminChecker.Name = "adminChecker"
adminChecker.Parent = player
adminChecker.Value = false
if player.UserId == adminsList[1] or adminsList[2] then
adminChecker.Value = true
end
end)
Lets take a look at the condition: if player.UserId == adminsList[1] or adminsList[2]
This is checking if the player’s UserId == adminsList[1] or if adminsList[2] exists.
Typing if yourVariable then means “if yourVariable exists, then (do whatever)”, with the exception of booleans; since that entry always exists, then your condition is always true
You should replace that if player.UserId == adminsList[1] or player.UserId == adminsList[2] then
I hope this works, but if it doesn’t fix your problem, it will fix a different one.
This fix will make it easier for you in the future if you decide to add more admins to the list. Instead of checking for individual variables, change it to loop through the table.
local adminsList = {
219993365,
472072511
}
game:GetService('Players').PlayerAdded:Connect(function(player)
local adminChecker = Instance.new("BoolValue")
adminChecker.Name = "adminChecker"
adminChecker.Parent = player
adminChecker.Value = false
for Key, Value in adminsList do
if (player.UserId == Key or player.UserId == Value) then -- either the key OR value can be their UserId. Especially useful if you change the structure of the table.
adminChecker.Value = true
end
end
end)