Adonis Admin ":team" command usable only by players

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?

This is what i tried:

settings.Permissions = {

“:team me:1”;

If you wish to do this, refer to the Commands.lua module in Server > Core > Commands for the full list of commands and their indexes.

1 Like

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

I didn’t understand anything about what you said. How do you access Adonis’s commands module and add it?

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.

1 Like

Should I add my plugins/extensions here as i understand?

[Edit thanks i understand now]

I believe you can and put my Function under the command function variable.


It looks like this and not working

Due to service and Functions not being defined. Also, insert Data as the last variable to get the PlayerLevel for this:

I guess I’m terrible at this, I still haven’t made it

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
};

Okay this code works well thanks for help!

All good, have a great day and happy coding.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.