Filtering Text Help


So I’m working on a game where players can place their own parts and add their own TextLabels onto the parts and change the text value. The same parts can then be loaded when the player rejoins the game.

The problem is that TextService:FilterStringAsync requires a players userid to filter the text. I am hoping there is a way to filter text without needing a player or player’s userid, and just filter all text to the most extreme amount.

Is the only other option to filter specifically for every player in the server, then send the filtered text to them to change on the client side? And then do that for every peice of existing text whenever a new player joins? Because this method seems a little long winded and would be harder to integrate into my current system.


Just filter the string once and then save it for future use. You don’t need to filter it every single time it’s seen or used.


Pick any player, but filter it for broadcast. That will use the most strict filtering.


I want to use the most up to date of the filter system - if I save text that has been filtered for broadcast to a datastore and then re-filter it when retrieving it at a later date, is this suitable enough?

The only downside is any strings that are currently filtered that aren’t in the future will still be filtered (unless re-entered by user).

1 Like

Yeah, just filter it for broadcast once per server. You can save the unfiltered value internally as long as nobody can see it.

1 Like

Yeah, but I don’t save text anywhere as it’s placed, I simply gather all data when the player leaves and save it all. This means that I won’t have any way of knowing the original unfiltered text when saving.

There are no filter methods that don’t require a Player(Id) to function. For the sake of staying on the safe side, if I ever have a need to filter but can’t fetch a player, I reject the text with “[ Content Deleted ]”. The Lua Chat System does this same thing when the endpoints are slow; text is replaced with underscores.

GetNonChatStringForBroadcastAsync (or the legacy FilterStringForBroadcast) is the only method available to filter specifically for all players in the server, though it still requires such information from players. You can’t get a filtering solution without passing something from a player.

For text, you should be caching raws on the server-side where possible. If you need to send that to a player’s screen, then filter the string first before sending it. You’re allowed to store raw unfiltered strings in a DataStore, so just save the raw and filter it any time a player needs to be sent it.

(which most of this is basically what posatta said)

If you don’t save text, rethink your structure to make it scale well and mesh with your system.

1 Like

If I can simply save filtered text and re-filter it when it’s added from a datastore again that would much easier than redoing the entire system. I don’t see any negatives to this method but I don’t want to implement it unless I’m sure there won’t be a problem with it?

I’ll look into redoing how saving/placing works but it may take a lot of time to start from scratch!

You’re allowed to do that, there are no issues. Naturally to make your code work, you kind of do need access to raw strings. Filtering is only relevant when players can fetch or see that string in any way shape or form.

I think I’ll do that then, since there is no need for the raw strings to be saved on the server, in this context at least. Thanks all!