Question about Chat:FilterStringAsync

In the wiki page for FilterStringAsync, it quotes “If the filtered string is to be used for a persistent message, such as the name of a shop, writing on a plaque, etc, then the function should be called with the author as both the sender and receiver.”

Is this still valid? Can I use this instead of FilterStringForBroadcast?

FilterStringForBroadcast has harsher filtering than FilterStringAsync. You may use FilterStringAsync with both the sender and receiver in the arguments but would have the same filtering as with a different receiver since the filtering is meant for what a specific player can see for the sender.

FilterStringForBroadcast has in mind that it is meant for everyone so it creates the harshest filtering possible to make sure that all users can see one appropriate filtered string.

So while you can do it, I wouldn’t recommend it for anything that would go public or to many people as it would keep in mind the settings of the sender rather than any possible receivers. For example, I believe 13+ users have more lenient filtering while users under have harsher filtering so if the sender was 13+ and you use the FilterStringAsync method, users under 13 would be exposed to a message meant for someone 13+ like the sender.

1 Like

So if I do use it, I won’t be moderated?

I agree that the docs are unclear about when to use which, but it seems like roblox wants you to use TextService:FilterStringAsync now.

This article goes into more detail.

This function can be used to filter strings meant for specific users or all users in chat and non-chat situations. TextFilterResult , the object returned by the function, has three methods that can be called: GetChatForUserAsync() , GetNonChatStringForBroadcastAsync() , and GetNonChatStringForUserAsync() .


The one exception to text filtering is when it comes to displaying text to a player that they wrote themselves, although there are still some considerations to keep in mind.

Sigh. I was hoping for a workaround instead of using GetNonChatStringForBroadcastAsync(). It’s so strict.

What’s your use case? There’s GetChatForUserAsync, which is for player-to-player chats, and GetNonChatStringForUserAsync, which I guess is for player-to-player messages that aren’t chats (?). They probably do the same thing, but the gist is that it will probably just take the stricter of the two player’s settings.

Obviously if you’re planning on showing any user-created text to any players, you would need to filter that for the strictest possible audience.

Players can create guilds in-game. I currently use GetNonChatStringForBroadcastAsync but it’s just amazingly strict. A lot of perfectly normal names end up being filtered.

Filtering it locally for every player would work but it seems inefficient.

I’m guessing you’re storing them in a data store? That article has this to say:

[When storing in a datastore], if the text that is being stored needs to be filtered, it is recommended to filter when retrieving the text.

So, I think a good design would be to store the plain text name in your datastore, and then filter per-player when they need to view the name. One filter request per player isn’t a huge deal.

You could also probably just make the request (TS:FilterStringAsync) once, and then call the Get...StringFor...Async methods on the same result every time. Maybe that would be faster, but you would also need to make sure that caching the result like that isn’t against the rules.

Pretty sure you shouldn’t be moderated against but probably should use the broadcastAsync functions for filtering when it comes to something seen by more than the reader.