I’ve made a code system for rewards, and I want the codes to get filtered so that people will have to go to wherever they have to to get the codes instead of them being leaked in chat, does anyone know where I can set my own words?
There is no way to do this with the default chat system, unfortunately. The only way would be to make a custom chat system where the codes get filtered in addition to being filtered normally through the Roblox chat filter. However, you could also fork the default chat and add the filtering you want into it if you are fine with it not receiving automatic updates.
Remember, it is against Roblox ToS to have an in-game chat (or any player-inputted text that is displayed to other players) where text is not filtered through the Roblox filter before being displayed to players.
yeah i did learn that the hard way a year ago
Maybe you can get the chat filtered by the default Roblox Filter but before you display the already filtered text you can put your own filter over it?
So it would be something like this:
Sends message → Roblox Filter → Your Filter → Display
Just an idea, I don’t know if it’s possible for your situation.
That’s what I was thinking about in the first place but there are like 50 scripts in the chat I don’t know where to start
This can be done quite easily with the default chat system without the need to fork the chat. You are able to add your own chat modules and still receive the default ones by deleting them and making sure InsertDefaultModules is true.
- Run your game and copy the ChatModules folder under Chat.
- Stop running and paste this under Chat.
- Delete everything but the bool value InsertDefaultModules from the ChatModules folder.
- Add your own ModuleScript with a filter function.
You can do something like this, but you will likely need a more complicated solution or players will be able to circumvent it quite easily:
local MyCodes = {"FreeStuff", "AmazingDeal"}
local ReplaceWith = "[Code]"
--- Could change this to hash out or do something like that.
local function replaceCode(message, startIndex, endIndex)
local startPart = string.sub(message, 1, startIndex - 1)
local endPart = string.sub(message, endIndex)
return startPart.. ReplaceWith .. endPart
end
local function Run(ChatService)
local function checkForCodes(sender, messageObject, channelName)
local messageLower = string.lower(messageObject.Message)
for i = 1, #MyCodes do
while true do
local code = string.lower(MyCodes[i])
local found = string.find(messageLower, code)
if found then
messageLower = replaceCode(messageLower, found, found + string.len(code))
messageObject.Message = replaceCode(messageObject.Message, found, found + string.len(code))
else
break
end
end
end
end
ChatService:RegisterFilterMessageFunction("checkForCodes", checkForCodes)
end
return Run
This is wrong. The default chat system is VERY customisable. You can do pretty much anything you want with it.
I was under the impression that this would cause the chat to be forked. Oh well.
Porting the chat system over to Lua really did open a lot of opportunities, such as the ability to add filtering to certain text on top of the required base filtering. That being said, while TheGamer101’s solution is pretty dank, it’s unfortunate that your checks are worthless in the end since they can be circumvented any number of ways. It’s rare that people leak codes in-game anymore anyway.
- Wikia
- YouTube
- Discord
- Any third party service, really
well it’s still a layer of defense lol, better than nothing
why’d you bump-post to reply to something that’s old… guess i have to reply.
I don’t believe in this whole “layers of defense” idea. It’s useless setting up something that can easily be bypassed. I wouldn’t waste my time trying to filter text input in my game to get people not to say codes, when no one even looks in-game for codes. It’s not hard to upload something to a third party website and for members to, say, Google it.
This thread isn’t about filtering out scam posts, it’s about applying a custom filter in order to prevent game codes from being spoken in the chat so that users actually have to find codes themselves to enter over being told them.
Scam posts can very easily be blocked since the pattern of speech is relatively the same across all implementations. You can search if a list of keywords exists in a spoken phrase and then block the message from being sent.