I’m just going to keep it short: I’ve been making a ROBLOX chat filter on my chatbot (with user input via a TextBox.), but when I do so, it keeps giving me errors.
My code is
local playerFrom = game.Players.LocalPlayer
local message = script.Parent.Text
FilteredString = game:GetService("Chat"):FilterStringForBroadcast (message, playerFrom)
script.Parent.FocusLost:connect(
function(enterPressed)
if enterPressed then
game:GetService("Chat"):Chat(game.Workspace.FrankieRichBoy.Head, FilteredString, Enum.ChatColor.White)
end
end
)
It’s all about the game:GetService(“Chat”):Chat (etc) line. after the game.WorkSpace.FrankieRichBoy.Head, it shows “FilteredString”, I want the filtered string to show up above the dummy’s head when a user puts in a swear word. But, it keeps giving me the error “message must be non-empty” . Does anyone know what the problem is?
Thanks for reading, it’s appreciated!

If you don’t have any default text in your textbox, it’s going to error because it does the filteredString stuff outside of that event. I think you wanted it to so it filters when you stop focusing, in which case, do this
local playerFrom = game.Players.LocalPlayer
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
local message = script.Parent.Text
local FilteredString = game:GetService("Chat"):FilterStringForBroadcast(message, playerFrom)
game:GetService("Chat"):Chat(game.Workspace.FrankieRichBoy.Head, FilteredString, Enum.ChatColor.White)
end
end)
So it gets the latest info from the textbox when enter is pressed
It doesn’t error anymore, but it does not filter the messages…?
Looking at the documentation on that command, It only works from the Server, it doesn’t work if you do it on the client, try this?
local playerFrom = game.Players.LocalPlayer
local textserv = game:GetService("TextService")
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
local message = script.Parent.Text
local FilteredString = textserv:FilterStringAsync(message,playerFrom.UserId):GetNonChatStringForBroadcastAsync()
game:GetService("Chat"):Chat(game.Workspace.FrankieRichBoy.Head, FilteredString, Enum.ChatColor.White)
end
end)