FilterStringForBroadcast is returning nothing when coming from a console player

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    im attempting to making a console chat for my game, and of course i want the msg’s to be filtered
  2. What is the issue? Include screenshots / videos if possible!

for some reason when filtering it, it returns nothing

  1. is with filtering
  2. isnt

image_2025-02-25_194644885
image_2025-02-25_194753216

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    ive tried all the filtering methods, but its not working

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Server handler

local remote = game.ReplicatedStorage:WaitForChild("Chat")
local remoteToXbox = game.ReplicatedStorage:WaitForChild("ChatToXbox")

local cantspeak = {}

remote.OnServerEvent:Connect(function(plr,msg)
	if not table.find(cantspeak,plr) then
		print(plr.Name.."   SENT:"..msg)
		local filtered = game:GetService("Chat"):FilterStringForBroadcast(msg,plr) --variable that returns nothing
		remote:FireAllClients(plr,filtered)
		table.insert(cantspeak,plr)
		task.wait(3)
		table.remove(cantspeak,table.find(cantspeak,plr))
	end
end)

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg,res)
		local filtered = game:GetService("Chat"):FilterStringForBroadcast(msg,plr)
		remoteToXbox:FireAllClients(plr,filtered)
	end)
end)

client display

game.ReplicatedStorage:WaitForChild("Chat").OnClientEvent:Connect(function(plr,msg)
	local color = ("#"..tostring(ComputeNameColor(plr.Name):ToHex()))
	local code = '"'
	local colortext = ("<font color="..code..color..code..">"..plr.DisplayName.." (XBOX)"..": ".."</font>")
	game:GetService("TextChatService").TextChannels.RBXGeneral:DisplaySystemMessage(colortext..msg)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

You should use TextService:FilterStringAsync() instead

Chat or ChatService is depreciated.
That is TextService not TextChatService.

1 Like

TextService, you are right. Whoops

doing this jsut halts the script forever, never returning anything

So there’s TextChatService and TextService that are not depreciated.

After calling TextService:FilterStringAsync(msg), you get a TextFilterResult
Then you call result:GetNonChatStringForBroadcastAsync() to get the properly filtered text.

this actually makes it work properly now!
i have 0 clue why the otyher didnt work, as it was that way even before chat was becoming deprecated.
Either way, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.