Can someone please tell me where ive gone wrong

Im trying to create an admin panel, the players.playeradded is running but the for loops arent working correctly?

--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

--// Variables
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local Panel = ServerStorage:WaitForChild("ScreenGui")

--// Tables - In the tables fill out the UserId of the user you would like to make admin/banned. This can be found on the players profile
local Admin = {"1"}
local Banned = {"22463101"}

game.Players.PlayerAdded:Connect(function(Player)
	--// Check for Banned
	for i,v in pairs(Banned) do
		if v == Player.UserId then
			Player:Kick()
		end
	end
	
	--// Check for Admins
	for i,v in pairs(Admin) do
		if v == Player.UserId then
			print("Is admin")
			--// Give them the admin panel
			local PanelCopy = Panel:Clone()
			PanelCopy.Parent = Player.PlayerGui
		end
	end
end)

try this


--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

--// Variables
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local Panel = ServerStorage:WaitForChild("ScreenGui")

--// Tables - In the tables fill out the UserId of the user you would like to make admin/banned. This can be found on the players profile
local Admin = {"1"}
local Banned = {"22463101"}

game.Players.PlayerAdded:Connect(function(Player)
	--// Check for Banned
	for i,v in pairs(Banned) do
		if v == tostring(Player.UserId) then
			Player:Kick()
		end
	end
	
	--// Check for Admins
	for i,v in pairs(Admin) do
		if v == tostring(Player.UserId) then
			print("Is admin")
			--// Give them the admin panel
			local PanelCopy = Panel:Clone()
			PanelCopy.Parent = Player.PlayerGui
		end
	end
end)
1 Like

I just realised - i was using strings in the tables instead of variables

1 Like

I think the loops are certainly running, and you can put a print in them to make sure. But UserId is a number, not a string. Either get rid of the quotes inside of the tables like so local Banned = {22463101} or do what Nube did.