How do I make chat commands not appear in chat with the new chat update

How can I make commands such as /tp /speed etc not appear in chat but still do their thing

You can use a TextChatCommand object that will sink the chat input.

Wait that exists? We actually have an event for commands? No more local msg:"/test" = <message>:split(" ")[1]?

You can try making the commands run with /e [command]. It doesn’t appear in chat and the message is still detected! I’ve seen many games use it. Another option is adding an gui to the game that executes commands separately from the chat.

can you please write me a simple piece of code for ex for tp cmd

Sure! I’ve created this example place file that has a teleport command working with the new TextChatService.

TeleportChatCommand Example.rbxl (41.9 KB)

Important details to callout are:

  • This will only work with files that have TextChatService.ChatVersion == Enum.ChatVersion.TextChatService. Any new file created after February 2023 will have this value enabled by default.
  • I’ve added TeleportChatCommand as a child of TextChatService. When you run the game, you may see other TextChatCommands that are created by default, like the emote command or help etc…
  • This particular TextChatCommand is ran from a LocalScript, but you may also write your command code from a server Script as well if that makes more sense. You can find this LocalScript in TextChatService.TeleportChatCommand.LocalScript.
  • I did not check for permissions if someone is allowed to run this command. You may want to consider checking if the sender is allowed to run your command.
  • doTeleportToPlayer is a ModuleScript I’ve included to actually teleport your character. It’s separated into its own ModuleScript so it’s easier to reuse and also separates your ChatCommand code from the actual behavior.

Here’s a sample of the TextChatCommand-specific code for reference which is found in the uploaded file:

--!strict
local Players = game:GetService("Players")

local TeleportChatCommand = script.Parent
assert(TeleportChatCommand and TeleportChatCommand:IsA("TextChatCommand"), "TeleportTextChatCommand is missing!")

local doTeleportToPlayer = require(script.doTeleportToPlayer)
TeleportChatCommand.Triggered:Connect(function(originTextSource, unfilteredText)
	local words = string.split(unfilteredText, " ")
	local otherPlayerName = words[2]

	local senderPlayer = Players:GetPlayerByUserId(originTextSource.UserId)

	if otherPlayerName then
		local otherPlayer = Players:FindFirstChild(otherPlayerName)
		if otherPlayer then
			print(`Teleporting to {otherPlayerName}!`)
			doTeleportToPlayer(senderPlayer, otherPlayer)
		end
	end
end)

Yup, it exists and will only work with TextChatService. For simple commands you won’t need to worry about using string.split however if you’d like to have a command that uses passed options from the sender you may still want to use string.split.


This is a clever solution but I’d recommend making your own commands instead of reusing the emote command. Who knows, there may be an emote with the same name as your command someday!

1 Like

There’s also /c system which you can type messages in without it being sent but you would need to re-enter it each separate time. The extra bonus for using this is that you don’t need to add a / or another prefix each time you use the command while in that channel.

Thank you so much for your help

1 Like

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