✓ Accepted answer
###As previously mentioned, it isn't a valid function of a string. Neither can you filter on the client, as the client can disagree to filter the text, thus any malicious text being broadcasted (such as not filtering the name of a pet). You could return some filtered text from the server and have the client get that text, with a RemoteFunction.
wait()
local ChatService = game:GetService("Chat")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FilterText = ReplicatedStorage:WaitForChild("FilterText")
FilterText.OnServerInvoke = function(player, text)
return ChatService:FilterStringForBroadcast(text, player)
end
###From the client:
wait()
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local text = script.Parent
local ChannelBox = PlayerGui.IntroP2.intop2fr.ChannelBox
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FilterText = ReplicatedStorage:WaitForChild("FilterText")
ChannelBox:GetPropertyChangedSignal("Text"):Connect(function()
text.Text = FilterText:InvokeServer(ChannelBox.Text)
end)
2 comments
FilterStringForBroadcast isn't a valid function of the Text property, it's a function of ChatService. If you want to filter text, you're going to have to call FilterStringForBroadcast on the server, since it's deprecated in local scripts. You're also going to have to use a RemoteFunction to return the text filtered.
Use it on the server, and it's game:GetService("Chat"):FilterStringForBroadcast(stringToFilter, playerFrom).