How could I make commands not show in chat?

My biggest problem with textchatcommands are that they appear in chat for everyone to see, and I don’t want that to happen. Can someone tell me how to hide them? (I am using textchatservice)

Image:

image

1 Like

Is switching to using TextChatCommands feasible in your case? Using those should hide the message by default.

If not, you could assign a callback to TextChatService.OnIncomingMessage, if the text matches a command, make a TextChatProperties, set the text to a whitespace character, then return it to hide this message

local textChatService = game:GetService('TextChatService')

local commandList = { -- placeholder example command list
	'gameversion'
}

function textChatService.OnIncomingMessage(message)
	local text = message.Text:lower()
	
	for _, command in commandList do
		if text:match(`^/{ command }`) then -- we hide the message
			local properties = Instance.new('TextChatMessageProperties')
			properties.Text = ' ' -- has to be a whitespace character
			
			return properties
		end
	end
end

I am already using TextChatCommands and they still show in chat.

Image here:

Ok, that’s odd, you’re making these commands on the server or in studio right?

2 Likes

I am making the commands on the client, welp I will probably have to change that. Thanks now I understand the problem.

1 Like