Hello, today we are making a custom chat filter. So to start off, just follow the directions below, or just feel free to look at the information or explanation!
INSTRUCTIONS
1: Press play, open the explorer by going in view/explorer, open the chat service and copy the chatmodules folder.
2: Press stop and paste chatmodules in the chat service.
3: Create a new modulescript in the chatmodules folder and name it whatever.
4: In the script, paste this line of code, I will explain what it does.
local BannedWords = {
WordExample = "lol";
SecondWordExample = "testing";
}
local function runFilter(Speaker, MessageObject, ChannelName)
for _, Word in pairs(BannedWords) do
if MessageObject.Message:match(Word) then
MessageObject.Message = "@Censored@"
end
end
end
local function runModule(ChatService)
ChatService:RegisterFilterMessageFunction(functionId, runFilter)
end
return runModule
EXPLANATION
So basically it creates a function id for the function, it then makes a table for all banned words. We then make a function called run filter which will run the filter of course, it gets all the banned words in the table and if the message contains one of the banned words then it will change the message to @Censored@, then the run module function will use the already made chat filter to filter out the words that we made in our function. Then it will run runModule.
INFORMATION
You may change or add any word you want to the banned words table. You may also change what it filters to. In the table, you may even change the semicolons into coma’s!
Also feel free to subscribe to my YouTube channel, pls:
I don’t recommend making a custom filter & just rely on the default filter. You also have a risk of getting your game deleted if you use a custom one.
Yes I agree with you. I also don’t recommend it especially if it does curse words, because a script having curse words could be moderated and sense cursing is against TOS, you can your game could get banned, or Roblox would find it and cry because they already made a chat filter and they worked hard on it. Thank you for pointing this out RealExotic
This can help to prevent bots / scams from happening.
If another bot wave happens (I hope it won’t) you can block phrases they use to prevent them from being able to tick anyone.
Forking ChatModules is not necessary and shouldn’t be done if you aren’t editing other ChatModules either. If you want the ChatService to initialise your filter functions then you can create a blank ChatModules Folder in Chat, then add a BoolValue named InsertDefaultModules and check it off.
Default filters still run on the processed message. Developer filter functions are applied to the message first and then the chat is delivered to TextService to be filtered accordingly. The minimum requirement is that Roblox filtering must be present however you will not get moderated for adding additional filters; this has been clarified by staff on relevant announcements.
It’s a whole lot more difficult to make a custom filter that’s as encompassing as Roblox’s internal filters but it’s still useful for more nuanced cases or for the sake of your game specifically.