Is there any way to block words other than ROBLOX filter?

Hello, I have a custom chat in my game and I want to block the words: “free”, “robux”, “bad_word”, “bad_word2”. What is the best way to do it?

local badwords = {"free", "robux", "bad_word", "bad_word2"}
event.OnServerEvent:connect(function(plr, x)
   local bool = true
   for i, v in pairs(badwords) do if ???? then bool = false end end
   if not bool then print("bad word") end
end)
4 Likes

You are required to filter all words that go from one player to another (or more) and it HAS to be using the Roblox one. You can however use your own filter after Roblox has filtered the current string you give it for that extra bit of security you’re aiming for.

1 Like

I already have Roblox filter. I am just trying to block more words for extra security.

1 Like
local TextService = game:GetService("TextService")
local string = "Hello"

function Filter(string, playerId)
   local filteredText = ""
   local success, errorMessage = pcall(function()
     filteredTextResult = TextService:FilterStringAsync(string, playerId)
   end)
  if success then
       for _, v in next, customFilter do
             if v then
                  return false -- bad word
             end
      end
     return filteredText -- all good
  end
end

I would do something like this.
Sorry for the poor indentation, can’t use TAB in this

1 Like

I have used string.spit() and it works.

local badwords = {"free", "robux", "bad_word", "bad_word2"}
event.OnServerEvent:connect(function(plr, text)
   local bool = true
   local table1 = string.split(text)
   for _, v in pairs(table1) do
       if not bool then break end
       for _, i in pairs(badwords) do if v == i then bool = false break end end
   if not bool then print("bad word") end
end)
2 Likes

Remember here that you MUST filter AFTER a string no longer will be modified. This means that you CANNOT do it after you have used Roblox’s filter.

Example:
Don’t
User chats → Roblox filter → your filter
Do
User chats → Your filter → Roblox filter

Remember that you must provide a player instance when filtering chance, and AFAIK there is no reason stated for it on the wiki (last time I checked), which means that if you’re doing something bad (making all players’ chats to bad sentences and then passing through the filter) it will be like the player actually said it.

This is what I think, though I have no evidence, don’t take my word for it, it means that it will appear like the player said the bad stuff. And if someone were to report, Roblox would probably have logs of the chat (since you filtered the text).

Example:
Player says “Hello friends!”
Developer turns it into “Something really bad with a lot of swearing”
Then the developer uses the filter system and then reports the player. If the developer is “smart”, they bypass the filter and make it look like the player said something bad, which they in fact didn’t.

This is just what I had on my mind.

1 Like