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

How would I filter this chat so no swearing and stuff?

Asked by
UPumpkin -34
5 years ago
Edited 5 years ago
game.Players.ChildAdded:connect(function(plry)
    if plry:IsA("Player") then
        plry.Chatted:connect(function(msg)
            local color = {"White"}
            local chat = game:GetService("Chat")
            chat:Chat(plry.Character.Head), msg, color[math.random(1,1)] )
        end)
    end
end)

0
:FilterStringAsync or something like that, I forgot greatneil80 2647 — 5y
0
if your making a bubble chat, why not just enable it from studios? A1exTatum 57 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

FilterStringAsync is what Roblox expects you to use for chat messages. In short, it takes three arguments. These arguments are, (the string, player who the string is from, player who the string is to).

What you'll want to do is run the unfiltered chat message to a server-script (since FilterStringAsync from LocalScripts is deprecated).

.Chatted:Connect(function(Message)
    game:GetService("ReplicatedStorage").RemoteEvent:FireServer(Message)
end)

You will then catch the message on the server's end, and iterate between each player and return it to the respective client.

.OnServerEvent:Connect(function(From, String)
    for _,v in pairs(game:GetService("Players"):GetPlayers()) do
        local FilteredString = game:GetService("Chat"):FilterStringAsync(String, From, v)
        ReplicatedStorage.RemoteEvent:FireClient(v, FilteredString)
    end
end)

You then catch the filtered string on the client, and use it as you want. In this case run it to your custom chat or whatever.

0
ty UPumpkin -34 — 5y
0
Or you could do FilterStringForBroadcast + FireAllClients Vulkarin 581 — 5y
Ad

Answer this question