What is a "TextObject"?

I’m trying to use TextService to filter things after learning about it yesterday. I was expecting FilterStringAsync to return a string but it returns a TextObject? What? What is that and how do I use it? I cannot find any documentation about it whatsoever.

Am I using it wrong?

game:GetService("TextService"):FilterStringAsync(tag, plr.UserId, Enum.TextFilterContext.PublicChat)

I think you’re looking for the TextFilterResult API, which is returned from TextService:FilterStringAsync. It returns an object because it provides 3 different methods to ensure text is filtered properly.

GetChatForUserAsync - Gets the properly filtered version for the chat. Takes a UserId.
GetNonChatStringForBroadcastAsync - Gets the properly filtered version for the entire game (eg announcement). Takes no parameters.
GetNonChatStringForUserAsync - Same as GetChatForUserAsync but not meant for the chat.

3 Likes

Finally, thanks! So why did they move the filtering stuff from Chat to TextService anyway? It appears to be largely the same (apart from this).

Since you may want to filter text that isn’t displayed in the chat, like a nickname system or text on SurfaceGuis. So it makes sense to seperate it from Chat, as that’s used mostly for chat-only functionality.

3 Likes