Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make a filtering system?

I tried to remake Roblox's old chat system. It works, but I know I need to make it filter so my game doesn't get banned.

For the filtering system, I wrote this:

--Server Script--
local TextService = game:GetService('TextService')

function game.ReplicatedStorage.FilterText.OnServerInvoke(toPlayer, fromPlayer, txt)
	print(toPlayer, fromPlayer
	)
	local textObject
	local s = pcall(function()
		textObject = TextService:FilterStringAsync(txt, fromPlayer.UserId)
	end)
	if s then
		return textObject:GetChatForUserAsync(toPlayer.UserId)
	else
		return '???'
	end
end
--Chat Script--
--some lines of code...
function Chat:ApplyFilter(str, fromPlayer)
	--[[for _, word in pair(self.Filter_List) do 
		if string.find(str, word) then 
			str:gsub(word, '@#$^')
		end 
	end ]]	
	return game.ReplicatedStorage.FilterText:InvokeServer(fromPlayer, str)
end
--more unimportant lines of code...

local text = Chat:ApplyFilter(message, cPlayer)
		mLabel.Text = nString .. text;

--even more unimportant lines of code...

I'm not sure if it's an error or not, but when I try to say something that usually gets filtered when I play Roblox, it doesn't. Please help me fix this!

EDIT: wait it worked all along nvm

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.