Quick script to filter out scam messages

It’s no surprise that we’ve recently had a big surge of scam bots joining games and spouting out scam messages, so I wrote a quick script that filters out scam messages by replacing their message entirely with something else.

-- Use in a LocalScript

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

local blacklist = {
    "bloxsdrop",
	"bloxdrop",
	"bloxdrep",
	"robux"
}

local function onIncomingMessage(textChatMessage: TextChatMessage)
	if not textChatMessage.TextSource then
		return
	end

	local message = string.lower(textChatMessage.Text)
	local overrideProperties = Instance.new("TextChatMessageProperties")

	for _, word in blacklist do
		if not string.match(message, word) then
			continue
		end

		overrideProperties.Text = "[Scam Message Filtered]"
		break
	end

	return overrideProperties
end

TextChatService.OnIncomingMessage = onIncomingMessage

It’s a bandaid solution so I hope this issue can be addressed soon.
If you see a new “key word” in these scam messages, just add it into the blacklist table.

6 Likes