Chat commands | Struggling to prevent the command from being outputted

I’m trying to make a chat commands script that allows the player to say another word if they use the command “/word”. In this case, when the player says “/word”, I
am wanting it to say “DRONESYSTEMS” and then hide the “/word” from the chat.

When I type “/word” in the chat, it successfully outputs “DRONESYSTEMS”, however, it does not hide “/word”.

Serverscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("ChatCMDS")

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msgs) 
		if msgs:lower() == "/word" then
			RemoteEvent:FireClient(plr,msgs) -- Send the message to the client
		end
	end)
end) 

Localscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("ChatCMDS")

local Chatting = false -- Variable to track if the player is currently chatting

local function Chat(msg)
	if game.ReplicatedStorage:FindFirstChild('DefaultChatSystemChatEvents') then
		game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(msg, "All")
	else
		game:GetService("TextChatService").TextChannels.RBXGeneral:SendAsync(msg)
	end
end

RemoteEvent.OnClientEvent:Connect(function(msg)
	if not Chatting then -- Check if the player is not currently chatting
		Chatting = true -- Set Chatting to true to prevent the player from chatting again
		Chat("DRONESYSTEMS") -- Use the message passed by the server
		wait(1) -- Wait for 1 second before allowing the player to chat again
		Chatting = false -- Set Chatting to false to allow the player to chat again
	end
end)

Let me know if more info is needed, thank you!

Do you mean that the previous sent “/word” should be removed?

Yes, I want the previous text “/word” to be removed.

Ah, alright.
Maybe this post might help you:

Thank you, but this hasn’t helped. I’m not sure where to find the chatgui.

Hold on, let me get yourself a script. It’ll take a moment

1 Like

I can’t help you with it, I’m sorry. My suggestion though is you can make a custom UI for commands

1 Like