Is there a way to add custom words to get filtered in the default roblox chat?


#1

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?


#2

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.


#3

yeah i did learn that the hard way a year ago


#4

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.


#5

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


#6

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.

  1. Run your game and copy the ChatModules folder under Chat.
  2. Stop running and paste this under Chat.
  3. Delete everything but the bool value InsertDefaultModules from the ChatModules folder.
  4. 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

#7

thank you


#8

This is wrong. The default chat system is VERY customisable. You can do pretty much anything you want with it.


#9

I was under the impression that this would cause the chat to be forked. Oh well.


#10

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

#11

well it’s still a layer of defense lol, better than nothing


#12

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.