I added a command that can only be used by users with the “Example” role to Adonis admin. This command changes the player’s team and I want to prevent someone with a higher rank than “Example1” from using it. For example, if a user has a rank of 10 as “Example”, I want to prevent someone with a rank of 11 from being able to use the command.
This is what i tried:
Example= {
Prefix = Settings.Prefix;
Commands = {"Example"};
Args = {"me"};
Description = "Changes your team to Example.";
AdminLevel = "Example";
Filter = true;
Hidden = false;
Function = function(plr, args, data)
local newTeam = plr.Team.Name -- Default to the player's current team
if args[1] == "me" then
-- Only allow the player to change their own team
newTeam = plr.Team.Name
else
-- If a team name is specified, check if it exists and allow the player to change to it if it does
local teamName = "Example"
local team = game:GetService("Teams"):FindFirstChild(teamName)
if team then
newTeam = team.Name
else
error("'" .. teamName .. "' not valid!")
end
end
-- Set the player's new team
plr.Team = game:GetService("Teams")[newTeam]
end
};
You can use the adonis server service called Admin to get the level of the player:
-- Assuming that you don't want to use a modulescript or function:
local target
for _,player in pairs(game.Players:GetPlayers()) do
if string.find(player.Name, args[1]) or string.find(player.DisplayName, args[1]) then
target = player
break
end
end
if not target then return end -- No such player found
local AdminLevel = server.Admin.GetLevel(target) -- Gives you a number value
if AdminLevel >= 100 then
-- Do stuff
end