How to check a text either it is caps or not (idk how to explain)

image People can still bypass it with this way

Try using the edit I made for it

1 Like

Ok so, I tried that and it does not work anymore and there is no errors

1 Like

Ok, I would say to make a loop through the banned words list and check if the filteredText contains any of the words

Example:

local list = {"string", "message"}
local wordToFilter = "message_string"

for _, word in pairs(list) do
   if string.find(wordToFilter:lower(), word) then
      print("filtered")
   end
end
1 Like

Ok so I know how to do a loop but wdym by “contains any of the words”

Ok so it works but doesn’t filter anything (it doesn’t even filter made by roblox) here is the code

local bannedWords = {"adolf", "german leader"} -- banned words list

script.Parent.OnServerEvent:connect(function(player,text)
	if text ~= "" then
		local filteredText = ""
		local success, message = pcall(function()
			for _, word in ipairs(bannedWords) do
				if string.find(filteredText:lower(), word) then
					filteredText = string.rep("#", #filteredText)
				else
					filteredText = game.Chat:FilterStringForBroadcast(text, player)
				end
			end
		end)
		if success then
			script.Parent.Parent.Name = filteredText
		end
	end	
end)
``

Roblox doesn’t censor that name… Plus I am using roblox filter already so it isn’t

I think it’s because after every word, it resets the text to an unfiltered state. If you’re using the roblox filter, you have to test it in-game

Edit: also, I think you should split the text by spaces so every word individually gets filtered

uh but right now it doesn’t even censor the words that roblox filter blocks

1 Like

are you testing the filter in studio

Uhm, yeah… but it was working before even in studio

strange. Trying using TextService to filter instead, since the filter from ChatService is deprecated not recommended

1 Like

eh trying to figure out how to use it but couldn’t

EDIT: not sure my way of using it is wrong but i tried removing the roblox filter it still not working, like nothing at all

local bannedWords = {"a d o l f", "german leader"} -- banned words list
local textserivce = game:GetService("TextService")
script.Parent.OnServerEvent:connect(function(player,text)
	if text ~= "" then
		local filteredText = ""
		local success, message = pcall(function()
		--	textserivce:FilterStringAsync(filteredText, player)
			for _, word in ipairs(bannedWords) do
				if string.find(filteredText:lower(), word) then
					filteredText = string.rep("#", #filteredText)
				end
			end
		end)
		if success then
			script.Parent.Parent.Name = filteredText
		end
	end	
end)

example:

local textService = game:GetService("TextService")
local message = "insert unfiltered message here" -- unfiltered message
local playerId = 0000 -- insert player to filter the message from, id's here

local success, err = pcall(function() -- the method has to make a web call, it may fail
   local result = textService:FilterStringAsync(message, playerId, Enum.TextFilterContext.PublicChat) -- text filter result
   return result:GetNonChatStringForBroadcastAsync() -- filter string
end)

if success then
  -- code
else
  -- error code
end

I think its because of

filteredText is blank by default

Oh, I just noticed what is the problem here and why it wasn’t filtering…

EDIT: Bruh that script was working without filter but now don’t work smh like nothing at all

1 Like

ok, i rewrote your script

local textService = game:GetService("TextService")
local bannedWords = {} -- words list

script.Parent.OnServerEvent:connect(function(player,text)
    if text == "" or not text then return end
    local filteredText = ""

    local success, err = pcall(function()
        local result = textService:FilterStringAsync(text, player.UserId, Enum.TextFilterContext.PublicChat)
        return result:GetNonChatStringForBroadcastAsync() -- filter text
    end)

    if success then
       filteredText = err

       local completed, output = pcall(function()
          local prevText = filteredText:split(" ")
          
          for _, word in ipairs(prevText) do
              local word2 = table.find(bannedWords, word) -- locate the word in the banned words list
              if not word2 then continue end -- if the word is not in the list then pass

              local wordFound = string.find(word, word2) -- location of where the word is found

			  if wordFound then
				 filteredText = filteredText:sub(string.rep("#", #filteredText), wordFound) -- replace where the word was located with hashtags "#"
			  end
		   end
       end)

       if success then
          script.Parent.Parent.Name = filteredText
       end
    else
       return warn ("unable to filtere text due to " .. err)
    end
end)
2 Likes

tysm, but however like you said before cause it was blank as default :stuck_out_tongue_winking_eye:

1 Like

oh god roblox fitler not working still

Try running it in-game, that might be the reason

1 Like