How to get message from chat and delete it?

Hello, I’m trying to find a if a blacklisted word appears in a chat message and if found deletes it. Currently, I have this:

local blacklistedwords = {"robux", "free"}
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(message)
		for i,v in pairs(blacklistedwords) do
			if message:Find(string.lower(blacklistedwords[i])) then
				-- delete message
			end
		end
	end)
end)

Thanks!

You cannot interfere with the chat from this way. Instead, you want to fork the chat scripts responsible for sending the messages and then deny the messages from that way.