So I have a game that when I release it I want there to be a full-fledged Custom Chat Gui but to not face moderation of the game I need to make the chat FilterStringForBroadcast, but the problem is I have to no idea on how to do that I have tried for multiple days and it has not worked at all. Is there any way you could help me make my chat filter work?
---Images -Chat Gui -ChatManager -Functions
---Scripts -ChatScript
local UIS = game:GetService("UserInputService")
local Chat = script.Parent
local ChatFrame = Chat.ChatFrame
local ChatBar = ChatFrame.ChatBar
local Frame = ChatFrame.SFrame.Frame
local OriginalText = ChatBar.Text
ChatBar.TextScaled = false
game.ReplicatedStorage.PlayerHasChat:FireServer()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,false)
if UIS.TouchEnabled then
OriginalText = "Press here to chat"
ChatBar.Text = OriginalText
end
UIS.InputBegan:Connect(function(Input,GameProcessed)
if GameProcessed then return end
if Input.KeyCode == Enum.KeyCode.Slash then
ChatBar:CaptureFocus()
end
end)
local function ChatFunction(Message)
game.ReplicatedStorage.Message:FireServer(Message)
end
ChatBar.FocusLost:Connect(function(EnterPressed)
if EnterPressed then
local Message = ChatBar.Text
if Message:len() > 1 then
ChatFunction(Message)
else
if Message:lower() == Message:upper() and Message ~= "" then
ChatFunction(Message)
end
end
end
ChatBar.Text = OriginalText
end)
ChatFrame.MouseEnter:Connect(function()
ChatBar.BackgroundTransparency = 1
Frame.BackgroundTransparency = 1
for i=1,5 do
ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency
Frame.BackgroundTransparency = Frame.BackgroundTransparency
wait()
end
ChatBar.BackgroundTransparency = 1
Frame.BackgroundTransparency = 1
end)
ChatFrame.MouseLeave:Connect(function()
ChatBar.BackgroundTransparency = 1
Frame.BackgroundTransparency = 1
for i=1,5 do
ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency
Frame.BackgroundTransparency = Frame.BackgroundTransparency
wait()
end
ChatBar.BackgroundTransparency = 1
Frame.BackgroundTransparency = 1
end)
game.ReplicatedStorage.Message.OnClientEvent:Connect(function(Message)
local i = Instance.new("TextLabel",Frame)
i.Size = UDim2.new(1,0,0.1,0)
i.BackgroundTransparency = 1
i.Font = Enum.Font.SourceSansSemibold
i.TextColor3 = Color3.new(255, 255, 255)
i.Name = "Chat"
i.Text = Message
i.TextSize = 30
i.TextXAlignment = Enum.TextXAlignment.Left
i.TextYAlignment = Enum.TextYAlignment.Top
local t = Frame:GetChildren()
Frame:ClearAllChildren()
if #t > 10 then
table.remove(t,1)
end
for c,v in pairs(t) do
local l = v:Clone()
l.Position = UDim2.new(0,0,(c-1)*0.1,0)
l.Parent = Frame
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
ChatBar.TextSize = ChatBar.AbsoluteSize.Y
for i,v in pairs(Frame:GetChildren()) do
if v:IsA("TextLabel") then
v.TextSize = 30
end
end
end)
-ChatManager
local ReplicatedStorage = game.ReplicatedStorage
local MessageEvent = ReplicatedStorage.Message
local APrefix = [[/]]
local Admins = {"vincentthecat1"}
local function IsAdmin(p)
local n = p.Name
for _,v in pairs(Admins) do
if v == n then
return true
end
end
return false
end
local function IsOwner(p)
if p.Name == "vincentthecat1" then
return true
end
return false
end
--// "p" is a Player
--// "m" is most likely a Message
local function Chat(p,m)
local Name = p.Name
local Message = game.Chat:FilterStringForBroadcast(m,p)
local Nick = p:FindFirstChild("Nickname") if Nick then Name = p.Nickname.Value end
local Prefix = p:FindFirstChild("Prefix") if Prefix then Name = "["..p.Prefix.Value.."]"..Name end
for _,v in pairs(game.Players:GetPlayers()) do
if not v:WaitForChild("Muted"):FindFirstChild(p.Name) then
MessageEvent:FireClient(v,Name..": "..Message)
end
end
end
local function SPM(p,m)
MessageEvent:FireClient(p,"SERVER: "..m)
end
local function SM(m)
MessageEvent:FireAllClients("SERVER: "..m)
end
local function RAW(m)
MessageEvent:FireAllClients(m)
end
local function PRAW(p,m)
MessageEvent:FireClient(p,m)
end
local function Whisper(p,v,m)
--// "p" is From
--// "v" is To
--// "m" is Message
local Name = p.Name
local Message = game.Chat:FilterStringForBroadcast(m,p)
local Nickname = p:FindFirstChild("Nickname") if Nickname then Name = p.Nickname.Value end
local Prefix = p:FindFirstChild("Prefix") if Prefix then Name = "["..p.Prefix.Value.."]"..Name end
if v:WaitForChild("Muted"):FindFirstChild(p.Name) then
PRAW(p,v.Name.." has muted you!")
else
PRAW(p,"Message Sent To "..v.Name)
PRAW(v,"From "..Name..": "..Message)
end
end
MessageEvent.OnServerEvent:Connect(function(p,m)
if m:sub(1,6):lower() == "/mute " then
m=m:sub(7)
local mu = p:WaitForChild("Muted")
for _,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower() == m:lower() then
if v ~= p then
if mu:FindFirstChild(v.Name) then
SPM(p,v.Name.." is already muted!")
else
SPM(p,v.Name.." was muted!")
local i = Instance.new("StringValue",mu)
i.Name = v.Name
end
else
SPM(p,"You cannot mute yourself!")
end
end
end
elseif m:sub(1,8):lower() == "/unmute " then
m=m:sub(9)
local mu = p:WaitForChild("Muted")
for _,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower() == m:lower() then
if mu:FindFirstChild(v.Name) then
SPM(p,v.Name.." was unmuted!")
mu:FindFirstChild(v.Name):Destroy()
else
SPM(p,v.Name.." is already unmuted!")
end
end
end
elseif m:sub(1,3):lower() == "/w " then
m=m:sub(4)
for _,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower() == m:sub(1,v.Name:len()) then
m=m:sub(v.Name:len()+1)
if m:sub(1,1) == " " then
m=m:sub(2)
Whisper(p,v,m)
end
end
end
elseif m == "/?" then
PRAW(p,"[Chat Commands]")
PRAW(p,"/mute player")
PRAW(p,"/unmute player")
PRAW(p,"/w player message")
PRAW(p,"/?")
elseif m:sub(1,1) == APrefix and IsAdmin(p) then
m=m:sub(2)
else
Chat(p,m)
end
end)
game.Players.PlayerAdded:Connect(function(p)
local mutedfolder = Instance.new("Folder",p)
mutedfolder.Name = "Muted"
end)
game.Players.PlayerRemoving:Connect(function(p)
SM(p.Name..", left the game!")
end)
game.ReplicatedStorage.PlayerHasChat.OnServerEvent:Connect(function(p)
SM(p.Name..", joined the game!")
SPM(p,[[Type "/?" for a list of Chat Commands]])
if IsAdmin(p) then
SPM(p,[[Type "/cmds" for a list of Admin Commands]])
end
end)

2 comments
What do you mean when you say that it doesn't work? Specifically, what behaviour do you expect, and what happens instead?
When I try it never works and keep restarting and what I expect is the roblox chat filter to filter the text a player sends if it contains a word roblox does not like and I have nothing happen. (Sorry for being a week or so late.))