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

Hello I am trying to make a custom filter system to censor some words but I am getting problems on how to detect a custom words using string
but I couldn’t figure out as I have read developer.roblox.com but was bit useless

here is script

script.Parent.OnServerEvent:connect(function(player,text)
	if text ~= "" then
		local filteredText = ""
		local success, message = pcall(function()
			filteredText = game.Chat:FilterStringForBroadcast(text, player)
			if filteredText == "Adolf" then
				filteredText = "#####"
			elseif filteredText == "Adolf. H" then
				filteredText = "########"
			elseif filteredText == "German Leader" then
				filteredText = "#########"
			elseif filteredText == "Adolfe" then
				filteredText = "#######"
			elseif filteredText == "ADOLF. H" then
				filteredText = "########"
			end
		end)
		if success then
			script.Parent.Parent.Name = filteredText
		end
	end	
end)

I know using elseif with that way is pretty bad and easy to bypass it that is why I am here to ask for help…

I tried using string.sub and string.lower() but they are not helpful in this situation, because I want it also to detect if it is either caps or not because somebody might do it with this way to bypass it “aDoLf”

1 Like

If s:upper() == s then that means s is all caps. If s:lower() == s then s is in all lowercase. For simplicity’s sake s:lower() == "adolf" is probably what you want to ignore casing but Roblox censors that name anyway and you shouldn’t assume that when they use that name they are referring to you know who.

2 Likes

I think he’s trying to add onto the Roblox filter, not replace it.
Anyway making a custom filter which replaces the original Roblox one is completely against the rules.

This should work. Support.

1 Like

I am not trying to replace roblox chat filter…

There is some words I want to censor only. custom words

You would have to consider Special Characters and Random Spaces but also if you want to go through with this you should make a function that counts the number of characters and adds a proportional amount of tags to save some time

1 Like

you can try something like

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()
			filteredText = game.Chat:FilterStringForBroadcast(text, player)
			if table.find(bannedWords, filteredText:lower()) or 
                 string.find(filteredText:lower(), table.unpack(bannedWords)) then
				filteredText = string.rep("#", #filteredText)
			end
		end)
		if success then
			script.Parent.Parent.Name = filteredText
		end
	end	
end)

Oh I completely forgot about that, thanks I will try it

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