Is there a way to make a chat command invisible in chat? (like :help wouldn't show up)

The title basically says most of it. I have a chat command which makes you change team to the choosing team, to choose a different team and would love it if when the user said :changeteams it would still change their team to choosing but it’d not show up in the chat.

I have no idea whether this is possible or not, but I’d love to try.

Current code which changes their team:

local teamname = "choosing"

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == ":changeteams" then
            plr.Team = game.Teams:FindFirstChild(teamname)
            plr:LoadCharacter()
        end
    end)
end)

image
(I don’t want that to show up in chat)

1 Like

you have to use the util chat module, i think

I mean I’m kind of new to scripting. I have been doing it for a long time and know advanced stuff but I’ve never ever touched on this.

Use string.sub and string.split

String.sub takes 2-3 arguments, the first being the chat string. The second is the minimum string character, so if I had the string “hello”, using string.sub(“hello”, 2) will return “ello”. If we use the third argument and for example string.sub(“roblox”, 2, 3) that will return “ob”

Now to grab all the words in a string we use string.split ontop of our string.
Like this string.split:(' ') the quotations in the split function are used for if you want to add stuff like comas after each word.

local reduced = string.sub(chat, 2)
local words = string.split(reduced, " ")
if string.lower(words[1] == "changeteams") then
	for _,v  in next, game:GetService("Teams"):GetChildren() do
		if string.lower(v.Name) == string.lower(words[2]) then
			plr.Team = v
			plr:LoadCharacter()
		end
	end
end

It’s early for me so if any of that was confusing, reply back to me.
Here are some additional documents on how you can achieve the desired behaviour.

1 Like

this seems to just change the contents of the string in the script but not in the actual chat itself. do you know how one would apply this new string in the actual chat?

The roblox default chat has an API, and you can call the module to remove different items from said chat