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

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

Yep it worked, thank you… it is becuz i was testing in studio which is very weird

1 Like