Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is FilterStringAsync() not filtering text?

Asked by 3 years ago

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
Make sure you are testing in RobloxPlayer and not in studio, filtering in studio does not work. imKirda 4491 — 3y

Answer this question