Help with custom chat filter

I’m creating a custom chat filter but I need to make the string lower case if I want to filter the message, is there any way around this? Here’s my code:

I’m using the lua chat system, which you can see here: Customizing In-Experience Text Chat | Documentation - Roblox Creator Hub

local words = {
	'hi'
}

local tag = '#'

function Run(ChatService)
	local function filter(speaker, messageObject, channelName)
		local msg = messageObject.Message:lower()
		
		for _, word in pairs(words) do
			local filtered = msg:gsub(word, tag:rep(#word))
			messageObject.Message = filtered
		end
		
	end
	
	ChatService:RegisterFilterMessageFunction('CustomChatFilter', filter)
end

return Run
1 Like

Do you have any errors in the output?

2 Likes

No, the problem is that I need to make the message lower case to filter it.

1 Like

use string.lower(string) to make everything in a string lowercase