I made my own chat filter to help reduce scams

Ok so the way it works is that blah blah blah you know…how about I show you

video of me and my alt when my alt say anything scam related

if you thing my alt just typed that here are the chat logs
rtfyhu

now for the scripting stuff B)

NOTE: LEAVE THE SCRIPT INSIDE WORKSPACE

  1. do this and name the scripts the same
    image

first the “ChatModuleAdder” script

local CSR = game.Chat:WaitForChild("ChatServiceRunner")
CSR.Disabled = true
for _,v in pairs(script:GetChildren()) do
	v.Parent = game.Chat:WaitForChild("ChatModules")
end
CSR.Disabled = false --ChatServiceRunner is now restarted and will load all added modules
script:Destroy() --the script has after this no purpose anymore

now for the “AntiBotModule” script

local WordsThatTheBotProbablyWillSayWhenHeComesToSpamYourGame = {"robux", " r$ ", "!" ,".",             " using ", "free", "check ", " go ", "browser", "visit", " instantly", "roux", "dot com"}
local ReplaceMessage = "Im a bot thats trying to scam and now I got kicked " --Feel free to modify :D
 
local function ScanForWords(msg)
local count = 0
for _,v in pairs(WordsThatTheBotProbablyWillSayWhenHeComesToSpamYourGame) do --loops through the list of words
	if(string.find(msg,v) ~= nil) then --matches words with the message
		count = count + 1 --if true, the total count will be increased with 1
	end
end
if (count > 3) then --when the message matches 4 of the words in the words list, change is huge that this is a bot
	return true
end
return false --if not a bot, the function returns false and no one gets hurt
end

local function Run(ChatService)
	
local function FilterRobuxWord(sender, messageObject, channelName)
	if(ScanForWords(string.lower(messageObject.Message))) then
		messageObject.Message = ReplaceMessage
		game.Players:FindFirstChild(sender):Kick()
	end
end

ChatService:RegisterFilterMessageFunction("makeLowercase", FilterRobuxWord)
end

return Run

If you are to lazy and want to just use the model here is the link

https://www.roblox.com/library/6941421351/anti-scam-chat-filter

Edit: also yes I know I suck at explaining things lol

7 Likes

Looks good, but wouldn’t it be better to tag the players message like this ###, when you find out its a scam message. then kick the player? That way this won’t just kick the bot it will also tag the message making it impossible to read, and therefore nobody can scam in your game. It may be a lot harder, but its better. the best way would probably be to delete the message though.

3 Likes

yeah but I like this so that way viewers know the username of the bot that tried to scam

2 Likes

You could at least tag the contents of the message

it is tagged, the filter replaces the message in game but the discord bot that runs my chat logs don’t pick up eddited/tagged messages for some reason

1 Like

Oh goodness, please never hot reload the ChatServiceRunner like that, it’ll result in unintended behaviours with your game. The modules are singletons so when they’re first required they’ll return the same instance but the same can’t be said for the initialisations ChatServiceRunner performs.

You can hook filter functions without ever putting code into the ChatService directly. You only need to have your ModuleScripts in ChatModules if you’re forking or want the ChatService to initialise with them. If not this, then the only change you need to make is how ChatService is indexed. ChatModules get it passed as an argument to the function they return, you’d just need to explicitly get it.

For a quick fix, change AntiBotModule into a script and replace return Run with:

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
Run(ChatService)

You can also place AntiBotModule directly into ServerScriptService and get rid of ChatModuleAdder when this is done since there’ll be no need for it anymore.

2 Likes

Ok, when I get on my pc im gonna go change that, thx for the correction