FilteredTextResult returning ' Instance '

Hi. This script always returns ’ Instance ’ on the Text Labels and I can’t figure out why.

game:GetService(“ReplicatedStorage”).HighwaySignChange.OnServerEvent:Connect(function(player, text)

local TextService = game:GetService("TextService")
local playerID = player.UserId
local filteredTextResult = TextService:FilterStringAsync(text, playerID)

for i, v in pairs(game.Workspace.Signs:GetChildren()) do
	v.Text.SurfaceGui.TextLabel.Text = tostring(filteredTextResult)
end

end)

Edit: No errors were outputted

1 Like

Which Instance is returned actually?

The text just says ’ Instance '. Let me get a gif.
https://gyazo.com/fd5ad303fb351542c965d9ffb7886708

What if you do:

v.Text.SurfaceGui.TextLabel.Text = tostring(filteredTextResult.ClassName)

It’s a ’ TextFilterResult ’
edit: TextFilterResult | Documentation - Roblox Creator Hub

Can you try this:

v.Text.SurfaceGui.TextLabel.Text = tostring(filteredTextResult:GetChatForUserAsync(playerID))
4 Likes

Yeah that works, but when I say a “bad word”, it doesn’t filter

Messages do not filter in Studio, if you were wondering.

Ah, ok. Let me try it in a game!!

Thanks, yup that worked! Just needed to do it ingame!

I can see it’s already solved but I want to give you the reason why - since it wasn’t elaborated on fully above. The reason this is happening is you’re trying to read a TextFilterResult (an Instance) as a string.

When you use TextService:FilterStringAsync, you’re not actually filtering it at that moment. You’re making an object (the TextFilterResult) which you can then use to filter stuff with.

Why is this good? Because it means that you can filter a string for each specific user. Let’s say you have a radio - instead of filtering messages using FilterForBroadcast, which will filter it to the highest severity possible, you can give an appropriate filtered string for each individual user, which improves your user’s experience.

A lot of the complaints people make about the Roblox filter come from developers using Broadcast where it’s not appropriate - there are very few cases where broadcast strings are actually appropriate, or that there isn’t a better way to display the text.

4 Likes

Great way to break it down, makes much more sense now. Thank you!

1 Like