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!
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.
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.