Cmdr Panel Creating Custom Commands

  1. What do you want to achieve?
    I want to make a ban command in cmdr panel using roblox’s ban async
  2. What is the issue?
    I cant seem to figure out how to do it.
  3. What solutions have you tried so far?
    I have tried doing it by seeing the other code but did not work and there are not any tutorials that i found about it.
    This is a simple code using roblox’s ban async in chat but i need to make it in Cmdr panel, please help me in this.
    The Code:
    local TCS = game:GetService(“TextChatService”)
    local Players = game:GetService(“Players”)

TCS.BanChatCommand.Triggered:Connect(function(TextSource, ChatText)
if TextSource.UserId == 3908064382 then
local splitString = ChatText:split(" ")

	 local username = splitString[2]
	 local reason = splitString[4]
	 if not reason then
			reason = "No Reason provided."
	 end
	 local duration = tonumber(splitString[3])
	 local ExcludeAlts = false
	 local PrivateReason = splitString[5]
	 if not PrivateReason then
			PrivateReason = reason
	 end
	
	 local userId = Players:GetUserIdFromNameAsync(username)
	 
	 Players:BanAsync({
		UserIds = {userId},
		DisplayReason = reason,
		PrivateReason = PrivateReason,
		Duration = duration,
		ApplyToUniverse = true,
		ExcludeAltAccounts = ExcludeAlts,
			
	 })
	
	
end

end)

Cmdr doesn’t work like that. To create a command you will first need to ensure this operations.

  1. List items
    Server Script:
-- This is a script you would create in ServerScriptService, for example.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Cmdr = require(ReplicatedStorage.Modules.Cmdr)

Cmdr:RegisterDefaultCommands()
Cmdr:RegisterHooksIn(script.Hooks)
Cmdr:RegisterTypesIn(script.Types)
Cmdr:RegisterCommandsIn(script.Commands)

-- Cmdr:RegisterCommandsIn(script.Parent.CmdrCommands) -- Register commands from your own folder. (Optional)
  1. Create the permissions.

  1. Create Client perm

  2. Final touch

2 Likes

Sorry for the late reply, I have modified it to my use, Thank you.

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