I am building a custom chat. Everything works fine, there are no errors. But for some reason, this script is not filtering the text when it should be. What I mean that bad words aren't being censored when it is supposed to.
The Chatted is a RemoteEvent that fires from the client and sends the text for filtering and distribution to all players.
local Chatted =script.Parent.Chatted
local TS = game:GetService("TextService")
Chatted.OnServerEvent:Connect(function(sender,value)
local newstring = nil
local newtext = nil
local success, errormessage = pcall(function()
newtext = TS:FilterStringAsync(value, sender.UserId)
end)
if success then
local success2, errormessage2 = pcall(function()
newstring = newtext:GetNonChatStringForBroadcastAsync()
end)
if success2 then
print(newtext)
for _,receiver in pairs(game:GetService("Players"):GetChildren()) do
receiver.PlayerGui.Events.Chatted:FireClient(receiver,sender.Name,newstring)
end
end
else
warn(errormessage2)
end
else
warn(errormessage)
end
end)

1 comment
Make sure you are testing in RobloxPlayer and not in studio, filtering in studio does not work.