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

FilterStringForBroadcast not filtering?

Asked by
Async_io 908 Moderation Voter
7 years ago

Okay, so I'm making a chat system, and I'm required to use the Filtering System. I checked the wiki, read it up and down about 2 times, and I've tried filtering, but it's not filtering, or I am using it incorrectly, or something. This is done via 2 different scripts, a server script and a local script.

Local script

local player = game.Players.LocalPlayer
local newchatline

game.ReplicatedStorage:WaitForChild("Events"):WaitForChild('Chatted').OnClientEvent:connect(function(player, message)
    local children = script.Parent.ChatGui.MainFrame:GetChildren()
    for i,oldmsg in ipairs(children) do 
        if i == 12 then 
            script.Parent.ChatGui.MainFrame:FindFirstChild(children[i].Name):Destroy()
        end
        oldmsg:TweenPosition(UDim2.new(oldmsg.Position.X.Scale, oldmsg.Position.X.Offset, oldmsg.Position.Y.Scale, oldmsg.Position.Y.Offset - 15), "Out", "Sine", 0.5)
    end
    newchatline = Instance.new("TextButton", script.Parent.ChatGui.MainFrame)
    newchatline.Text = player.Name.. ": " ..(game:GetService("Chat"):FilterStringForBroadcast(message, player))
    newchatline.Size = UDim2.new(1,0,0,15)
    newchatline.Position = UDim2.new(0,0,1,-15)
    newchatline.Font = "Fantasy"
    newchatline.TextColor3 = Color3.new(1,1,1)
    newchatline.TextStrokeTransparency = 0.3
    newchatline.BackgroundTransparency = 1
    newchatline.BorderSizePixel = 0
    newchatline.FontSize = "Size14"
    newchatline.TextXAlignment = "Left"
    newchatline.TextYAlignment = "Top"
    newchatline.ClipsDescendants = true
    newchatline.Name = (player.Name)
    print(game:GetService("Chat"):FilterStringForBroadcast(message, player))
end)

Server script

local chatted = game.ReplicatedStorage:WaitForChild('Events'):WaitForChild('Chatted')
local filteredmessage = ""
chatted.OnServerEvent:connect(function(player, msg)
    local success, message = pcall(function()
        filteredtext = game:GetService("Chat"):FilterStringForBroadcast(msg, player)
    end)
    if  success then 
        chatted:FireAllClients(player, filteredtext)
    end
end)

I'm not receiving any issues, and it's working correctly, it's just not filtering.

Answer this question