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

3 comments
XD
10/10 answer
im reporting dun dun dunnnnn (not really)