How do i make custom commands for Cmdr

How do i make custom commands for Cmdr
Thats about it i got it setup i just need to know how to make the custom commands i looked on the website and i dont understand how to do it if you could provide a video or explanation on how to do this please let me know!

1 Like

Here’s a template with comments to guide you. I recommend doing research and looking at the existing commands to learn how they are laid out and made.

Name this module to command name

return {
	Name = "kick";
	Aliases = {"boot"};
	Description = "Kicks a player or set of players.";
	Group = "DefaultAdmin";
	Args = {
		{
			Type = "players";
			Name = "players";
			Description = "The players to kick."; --you can input their usernames when the type is players, I recommend doing research on the types.
		},
		{
			Type = "string";
			Name = "reason";
			Description = "The reason to kick the player."; --Make sure to include the name and description
		},
	};
}

Name this to the command name but add server at the end

return function (_, players, reason) --returns the command
	for _, player in pairs(players) do --this gets the player
		player:Kick("You have been kicked for "..reason) --includes the kick reason.
	end

	return ("Kicked %d players."):format(#players) --tells you how many players were kicked
end
2 Likes

The best way is using string.split(Strint,Seperator)

So when a player chats you split up what they say. Or a textbox

function OnChat(Text)
local SplitVer = string.Split(Text," ") – split at spaces
if SplitVer[1].lower == “kick” then
– find and kick SplitVer[2]
end
end

So if I was to say “:kick minimic2002”
SplitVer will become {":kick",“minimic2002”}

String.Split will split up wherever it find the seperator, the seperator is just string and can consist of multiple characters.

1 Like

Im talking about this

Not a entire admin script

1 Like

There’s a documentation for it.
You’ll have to tweak in BuiltInCommands in the Cmdr ModuleScript.
Select any category (Admin, Debug, Utility)
Categories!
Then, create 2 modulescripts. One named as your command and another named the exact same but with “Server” at the end.
Let’s say I want to make a command named test. You’d have to make a first ModuleScript named “Test” and another one named “TestServer”.
In the first ModuleScript (Test), it would look like this.

return {
	Name = "test";
	Aliases = {};
	Description = "Prints something in the console.";
	Group = "DefaultAdmin";
	Args = {
		{
			Type = "string";
			Name = "text";
			Description = "The text to print.";
		},
	};
}

The server ModuleScript would then look like this.

return function (context, text)
	print(text)
	return "Printed the text."
--What is returned here will show in the Cmdr command bar
end

This is a very barebone tutorial but you’d get the idea.

2 Likes

Ok so i did what you said and tryed to make my own command as a start its a simple command where you just change a int value of a int value object but it wont work heres the module script (not server)

return {
Name = "Core Temp";
Aliases = {};
Description = "Changes Core Temp";
Group = "DefaultAdmin";
Args = {
	{
		Type = "number";
		Name = "TempNumber";
		Description = "Core Temp Number";
	},
};
}

And heres the 2nd module script (server)

return function (context, text)

game.ServerScriptService.CoreExplosionScript.CoreTemp = text

return "Core Temp Changed."

--What is returned here will show in the Cmdr command bar

end
2 Likes

Try this instead:
game.ServerScriptService.CoreExplosionScript.CoreTemp.Value = text

2 Likes

Oh opps my bad i forgot to put that

Now i get this error
04:50:53.149 Core_Temp command has no implementation!
@QuaternionIdentity

Ok so ive noticed that if i put the 2 scripts i made inside the admin folder or any other folder i can use the command (it still doesnt work cause of the error) but anyways when i put it in one of the folders i cant use some of the commands like the help command even though when i misspell a command or something it says use the help command to get a list of commands and i can only use that command and many more when i remove the 2 scripts i made

You should create a folder in ServerStorage and name it “Commands” and add this line to the Cmdr server activation script

Cmdr:RegisterCommandsIn(game.ServerStorage.Commands)

Now you should store the custom commands in this folder. Otherwise adding custom commands to the BuildInCommands folder may break the system.
Also make sure to read the commands guide.

1 Like

Ok so i cant use the help command and the command i added to the folder isnt showing up

Make sure to add this line

Cmdr:RegisterCommandsIn(game.ServerStorage.Commands)

To the Cmdr server activation script.

2 Likes

I did add that
Yes1

Ok so apparently my commands i made werent in the commands folder somehow so when i moved them into it, it made the default commands work now i just need to get the command i made working because right now im getting this error
Yes1

Hey i also get this error. Have you fixed your problem? cause im trying to find out how to make a command work!

@spydercam500 @Not0ffSale You need to either define a ClientRun function in the command definition module or create a separate module with the suffix -Server, like kickServer. You would use ClientRun in the command if the command can run entirely on the client.