How I make a Admin Script? Part 2

did my topic get reset? for me it reset

What do you mean??

char

i was in 6 post and the other didnt exist

anyways lets go back to what i was talking

imagem_2022-03-06_190741
so the script should be like this?

Do this instead:

local ui = script.AdminGUi

ui:Clone().Parent = Player.PlayerGui
1 Like
local admins = {
	require(script.Parent.Settings).Ranks
}
local ui = script.AdminGUI
function IsAdmin(player)
	for _,Admin in pairs(admins) do
		if Admin == player then
			return true
		end
	end
	return false
end

game.Players.PlayerAdded:Connect(function(Player)
	if IsAdmin(Player.Name) then
		ui.Parent = Player.PlayerGui
	elseif ui:Clone().Parent == Player.PlayerGui and not admins then
		Player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
	end
end)

Just so you know, admins is a table, you won’t be able to check for that I believe.

elseif Player.PlayerGui:FindFirstChild("AdminGUI") == Player.PlayerGui and not admins then

game.Players.PlayerAdded:Connect(function(Player)
	local AdminCheck = IsAdmin(Player.Name)
	if AdminCheck then
		ui.Parent = Player.PlayerGui
	elseif Player.PlayerGui:FindFirstChild("AdminGUI") == Player.PlayerGui and not AdminCheck then
		Player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
	end
end)

Edit: You would not have to do that check if you do not have that GUI visible to the client. Example would be in the workspace. If you had your GUI in ServerStorage, exploiters would not be able to access the UI anyway.

1 Like

if your thinking what in the settings table here it:

return {
	Ranks = {
		[3236301256] = true
	}
}

You weren’t referencing that in your script. You were just referencing the ‘admins’ table.

i used module script because i dont my script be messy

I know what you were using to store the admin ID’s but you were not referencing it in your elseif statement.

1 Like

if i knew that it would take not long

Try this:

local admins = {
	require(script.Parent.Settings).Ranks
}

function IsAdmin(player)
	for _,Admin in pairs(admins) do
		if Admin:lower() == player:lower() then
			return true
            return Admin
		end
	end
	return false
end

game.Players.PlayerAdded:Connect(function(Player)
	if IsAdmin(Player) then
		local ui = script.AdminGUI:Clone()
		ui.Parent = Player.PlayerGui
	elseif script.AdminGUI:Clone().Parent == Player.PlayerGui and not Admin then
		Player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
	end
end)

im changing the Name to UserID because Userids cant be changed and prevents it

@oofdog4526 is this script good?

local admins = require(script.Parent.Settings).Ranks

function IsAdmin(player)
	for _,Admin in pairs(admins) do
		if Admin == player.UserId then
			return true
		end
	end
	return false
end

game.Players.PlayerAdded:Connect(function(Player)
	local AdminCheck = IsAdmin(Player.Name)
	if AdminCheck then
		local ui = script.AdminGUI:Clone()
		ui.Parent = Player.PlayerGui
	elseif Player.PlayerGui:FindFirstChild("AdminGUI") == Player.PlayerGui and not AdminCheck then
		Player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
	end
end)

also i removed the table because and when i tried return Admin it show as red.

If there is no table, how can you do in pairs?

i didnt noticed, so i remove in pairs?
of course yes

Well, you could just bring the table back, unless you removed it for a specific reason.

i added back

local admins = {require(script.Parent.Settings).Ranks}