Why does my third party chat filter only censor one bad word?

Hello, and I have problem, Why does my third party chat filter only censor one bad word?
Here is my script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local HTTPService = game:GetService('HttpService')
local Chat = game:GetService('Chat')
local History = {}

game:GetService('Players').PlayerAdded:Connect(function(player)
	wait(1)
	ReplicatedStorage:WaitForChild('GetChatHistory'):FireClient(player, History)
end)

ReplicatedStorage:WaitForChild('Chat').OnServerEvent:Connect(function(player, text)
	if text == '' then
	else
		local Url = 'https://api.sightengine.com/1.0/text/check.json?text='..text.."&mode=standard&lang=en&opt%5Fcountries=gb&api%5Fuser=xxxxxxx&api%5Fsecret=xxxxxxxxxx" -- make sure to url encode your api_secret and api_user
		local RequestData = {
			['request'] = {
				["text"] = text,
				["mode"] = 'standard',
				['lang'] = 'en',
				['opt_countries'] = 'gb',
				['api_user'] = 'xxxxxxxx',
				['api_secret'] = 'xxxxxxxxxx'
			}
		} -- we still use RequestData just in-case some properties are accessed from the post data.
		local RequestData = HTTPService:JSONEncode(RequestData)
		local ModeratedHTML = HTTPService:PostAsync(Url, RequestData)
		local DecodedJSON = HTTPService:JSONDecode(ModeratedHTML)
		local Filtered = text
		print(DecodedJSON)
		for _, profanity in pairs(DecodedJSON.profanity.matches) do
			local swearword = string.sub(text, profanity.start+1, profanity['end']+1)
			Filtered = string.gsub(text, swearword, string.rep('*', string.len(swearword)))
		end
		for _, personal in pairs(DecodedJSON.personal.matches) do
			local swearword = string.sub(text, personal.start+1, personal['end']+1)
			Filtered = string.gsub(text, swearword, string.rep('*', string.len(swearword)))
		end
		for _, link in pairs(DecodedJSON.link.matches) do
			local swearword = string.sub(text, link.start+1, link['end']+1)
			Filtered = string.gsub(text, swearword, string.rep('*', string.len(swearword)))
		end
		ReplicatedStorage.RecieveChat:FireAllClients('['.. player.DisplayName.. ']: '.. Filtered)
		Chat:Chat(player.Character.Head, Filtered, Enum.ChatColor.White)
		table.insert(History, '['.. player.DisplayName.. ']: '.. Filtered)
	end
end)

So the chat filter doesn’t censor multiple bad words, The script only censors one bad word for some reason.

3rd party chat filters aren’t allowed, unless you’re filtering the text via Roblox’s filter beforehand.

3 Likes

Hi! I’m not exactly sure what the problem is, but I just want to let you know that I’m pretty sure using any other text filter than Roblox’s official one is against the TOS. I’m not 100% sure, though.

1 Like

I think you run a risk here of getting your game banned or deleted. If they parse your list of swearwords it will look like your game is generating them. IDK though, be careful. Your good intentions may bite you.

The chat filter is from HttpService.