How do I delete a chat message?

Yes charscharscharschars

Alright, I did that and the script is now:

local function processMessage(message)
	if string.lower(tostring(message)) == "!buy space" or string.lower(tostring(message)) == "!buy speed" or string.lower(tostring(message)) == "!help" then
		return true
	end
	return false
end

local function runChatModule(ChatService)
	ChatService:RegisterProcessCommandsFunction("processMessage", processMessage)
end

return runChatModule

But it still doesn’t work…?
I tried it in-game outside of studio too.

Sorry, I forgot to add SpeakerName in the parameters.
New Script:

local function processMessage(speakerName, message)
	if string.lower(tostring(message)) == "!buy space" or string.lower(tostring(message)) == "!buy speed" or string.lower(tostring(message)) == "!help" then
		return true
	end
	return false
end

local function runChatModule(ChatService)
	ChatService:RegisterProcessCommandsFunction("processMessage", processMessage)
end

return runChatModule

Explorer View:
image

“RegisterProcessCommandsFunction” guide used:

Credits:
comsurg

1 Like

The code I wrote was for client-sided command modules which in retrospect is not the brightest idea for creating a chat filtering system. The principles of the thread however in that you should be preventing the message from being sent rather than finding a way to delete it hold up.

The linked script stops the message from being sent to the server if the client sees a tag in the message but realistically tags don’t get added until the message reaches the server. I haven’t exactly updated that post but maybe it might be a good idea to do that if people are still finding that to help resolve their problems, so thanks for letting me know with the thread link.

1 Like