Help with custom chat filter

So I want to make a chat custom chat filter that fires a remote event when a player says a word that is filtered but I am not exactly how to do this. I used the developer hub chat filtering tutorial to make this btw

local util = require(script.Parent:WaitForChild("Util"))
local RepStorage = game:GetService("ReplicatedStorage")
local event = RepStorage:WaitForChild("ToxicLanguage")

--Add any phrases or words to this table
local toxicChats = {
	"ez",
	"trash",
	"noob",
	"shut",
	"nub",
	"mic up",
	"cry",
	"bad",
	"imagine",
	"suck",
	"dumb",
	"idiot"
}
function ProcessMessage(message, ChatWindow, ChatSetting)
	message = string.lower(message)
	for i=1,#toxicChats do
		if message:find(toxicChats[i]) then
			event:FireServer()
			return message
		else
			
		end
	end
end

return {
	[util.KEY_COMMAND_PROCESSOR_TYPE] = util.COMPLETED_MESSAGE_PROCESSOR,
	[util.KEY_PROCESSOR_FUNCTION] = ProcessMessage
}

So i think it would be more better to use player.Chatted, becouse you get the message player chatted, you can look if it contains any bad words, and than if it does you can remote send to that player who chatted.

Here is my code:

Option 1: If you want to do anything on server when player is bad talking, u dont have to use RemoteEvent:

local toxicChats = {
	"ez",
	"trash",
	"noob",
	"shut",
	"nub",
	"mic up",
	"cry",
	"bad",
	"imagine",
	"suck",
	"dumb",
	"idiot"
}

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		msg = string.lower(msg)
		for i=1,#toxicChats do
			if msg:find(toxicChats[i]) then -- looks for bad words in message player chatted
				player:Kick("Bad words")
			end
		end
	end)
end)

On the other hand, if you would like to do anything just locally on players computer, when he is bad talking, than i woul use Remote Event:

serverscript:


local toxicChats = {
	"ez",
	"trash",
	"noob",
	"shut",
	"nub",
	"mic up",
	"cry",
	"bad",
	"imagine",
	"suck",
	"dumb",
	"idiot"
}

local re = Instance.new("RemoteEvent",game.ReplicatedStorage) --creates event in ReplicatedStorage
re.Name = "toxicChattedEvent" --change it to whatever you want

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		msg = string.lower(msg)
		for i=1,#toxicChats do
			if msg:find(toxicChats[i]) then -- looks for bad words in message player chatted
				re:FireClient(player)
			end
		end
	end)
end)

and localscript (dont forget to move it to StarterCharacterScripts or StarterPlayerScripts):

game.ReplicatedStorage.toxicChattedEvent.OnClientEvent:Connect(function()
       game.Players.LocalPlayer:Kick("Bad words")
end)

Damn bro you about 6 months late