How I make a Admin Script?

Hi, i was scripting and i wanted to make a admin script. I already made one but i think is easily bypass, here the code:

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

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

game.Players.PlayerAdded:Connect(function(plr)
	if IsAdmin(plr.Name) then
		script.AdminGUI:Clone().Parent = plr.PlayerGui
	end
end)

If you know to make one advanced, please tell in the comments!

3 Likes

are you making an admin gamepass??

To block the bypassing, i suggest you checking the player’s rank when the player fires the command event. Heres an example:

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

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

game.ReplicatedStorage.Command.OnServerEvent:Connect(function(Player, Command, ...)

if Command == nil then return end


if IsAdmin(Player) == true then
-- Player has access
  ...
else
-- Player doesn't have access
   ...
end



end)

This example will make exploiters unable to use commands even if they reach to the Admin panel.

Hope this helps :slight_smile:

2 Likes

No, if i made it, everyone will spam “;kill [someone]”.

1 Like

It works but i want to kick a player if he bypass it.

1 Like

Also i recommend using game.Players.PlayerAdded because if using game.ReplicatedStorage.Command.OnServerEvent the script will only do something when it fires it.
For example:

game.ReplicatedStorage.Remotes.Command.OnServerEvent:Connect(function(Player, Command)
	if Command == nil then return end
	if IsAdmin(Player) == true then
		script.AdminGUI:Clone().Parent = Player.PlayerGui -- copy and paste it to the player
	else
		print("Player doenst have access")
	end
end)

Use game.Players.PlayerAdded because it will fires when a player joins.

I don’t think this is needed cause what will it do
ExampleValue: Player

if the ExampleValue is all small characters (“player” not “Player”) then, proceed. If not then don’t

I’m using string.lower(Admin) because i thought it will only give to the player with the letters Perfectly

Well it’s on a wrong spot, must be

if Admin:lower() == player:lower() then

No 2nd statement (or/and)

I will test it if it works, if it dont then i will other way

1 Like

Uhhhhhh…
1

2
Fun fact: i added key so if i press b i will open i tryed but didnt work

imagem_2022-03-06_011458
Is this a bug or roblox studio itself??

You must create a variable or and double clone statement here, like

script.AdminGUI:Clone()
script.AdminGUI:Clone().Parent = parent

Or

local ui = script.AdminGUI:Clone()
ui.Parent = parent

So the parent must be the playergui???

Obviously, if that’s what your trying to do?

Yes.But if a player get the gui if hes not a admin?
Should i kick or remove the gui from him?

Kick will kicking him from the server meaning i will reset the guis (not the datastore)

Remove the ui? It will prolly remove the entertainment of users if yur gonna kick the person because of a bug

i mean, if i remove the gui should remove the admin gui?

1 Like

But could you exactly tell me how could they bypass the ui?