---
title: "Custom text chat commands"
url: /docs/en-us/chat/examples/custom-text-chat-commands
last_updated: 2026-06-19T03:26:14Z
description: "Learn how to create custom chat commands."
---

# Custom text chat commands

`Class.TextChatService` has built-in chat commands for common purposes, such as muting other players and using avatar emotes. You can enable them by setting `Class.TextChatService.CreateDefaultCommands|CreateDefaultCommands` to `true` in Studio's **Properties** window.

You can also add custom commands using `Class.TextChatCommand`. Users sending a defined command in the chat input bar trigger a callback defined by `Class.TextChatCommand.Triggered` to perform your customized actions.

The following example shows how to create a chat command that allows players to increase or decrease their character's size when they input `/super` or `/mini`.

1. Add a `Class.TextChatCommand` instance inside `Class.TextChatService`.
2. Rename it to **SizeCommand**.
3. Set its `Class.TextChatCommand.PrimaryAlias|PrimaryAlias` property to `/super` and its `Class.TextChatCommand.SecondaryAlias|SecondaryAlias` to `/mini`.
4. Insert the following `Class.Script` inside `Class.ServerScriptService` to define a callback for the chat command that scales the character's size:```lua
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

local sizeCommand: TextChatCommand = TextChatService:WaitForChild("SizeCommand")

sizeCommand.Triggered:Connect(function(textSource, message)
	local scaleMult = 1
	local messageWords = string.split(message, " ")
	if messageWords[1] == "/super" then
		scaleMult = 2
	elseif messageWords[1] == "/mini" then
		scaleMult = 0.5
	end

	local player = Players:GetPlayerByUserId(textSource.UserId)
	if player then
		local character = player.Character
		if character then
			local humanoid = character:FindFirstChildWhichIsA("Humanoid")
			if humanoid then
				for _, child in humanoid:GetChildren() do
					if child:IsA("NumberValue") then
						child.Value *= scaleMult
					end
				end
			end
		end
	end
end)
```