Hello, I am trying to make the “:team” command usable only by players with a level 1 rank. Additionally, it should only be usable by the player themselves and not other players. Can you assist me with this?
I don’t quite understand what you mean, but inside Adonis Admin I have possibility to change such things only in ‘settings’ module. There is no “Commands.lua”.
Adding onto this, you can use a custom module to edit the command and it’s functionality:
return function()
--// Change the command to check for stuff:
server.Commands.SetTeam.Function = function(plr, args)
--// Defined Arguments for ease
local target = args[1]
local team = args[2]
-- Example of if function using arguments
If plr.Name == target then
--// Run stuff
end
end
end
Refer to the Adonis_Loader > Config > Plugins folder, that’s where you add the Module. Please refer to Adonis - Adonis Plugins & Modules. I have provided all needed.
ExampleCommand1 = {
Prefix = Settings.Prefix;
Commands = {"team"};
Args = {"teamName"};
Description = "Changes your team.";
AdminLevel = 0;
Function = function(plr, args)
if args[1] == "me" then --// Check if the command is using the "me" argument
local teamName = plr.Team.Name --// Get the player's current team name
local newTeamName = args[2] --// Get the new team name from the command arguments
if newTeamName == nil then --// Check if the new team name is provided
plr:Chat("Please provide a team name.") --// Error message if new team name not provided
return
end
if newTeamName == teamName then --// Check if the new team is the same as the current team
plr:Chat("You are already on the " .. teamName .. " team.") --// Error message if new team is the same as current team
return
end
local team = game.Teams:FindFirstChild(newTeamName) --// Find the team with the given name
if team then
plr.Team = team --// Set the player's team to the given team
print("You have been moved to the " .. newTeamName .. " team.") --// Optional success message
else
plr:Chat("The team '" .. newTeamName .. "' does not exist.") --// Error message if team not found
end
else
plr:Chat("This command can only be used as ':team me [team name]' to change your own team.") --// Error message if the command is used with another player's name
end
end
};