Hello, I’m Bunnyh_Script. I’m creating a Custom Chat… The Chat Script are okay. But I can’t figure out how to make a working Filter System. I already checked the wiki, but I still can’t do it.
The Script that I’m currently using:
-- Variables
local TextService = game:GetService('TextService')
local Events = game.ReplicatedStorage.Events
local Chat = Events.Chat
-- Main
Chat.OnServerEvent:Connect(function(Message, ID, Player)
local function Filter(ToUserId)
local Success, Result, Error = pcall(TextService.FilterStringAsync, TextService, Message, ID, Enum.TextFilterContext.PublicChat)
if Success then
local Filtered, Error = pcall(Result.GetChatForUserAsync, Result, ToUserId)
if Filtered then
Chat:FireAllClients(Filtered, Player.Name)
else
warn(Error)
end
elseif Error then
warn(Error)
end
end
Filter()
end)
If you could help, I would be so happy.