-
What do you want to achieve?
I want a way for users to create and share their own levels within my game. The levels will have an associated name and description that the creator can write. Other players will be able to see other players levels on their profile. -
What is the issue?
I’m not sure how exactly to do text filtering in this case. The text filter doesn’t allow filtering of messages from players not online/in a different server as far as I know, so I can’t do something like this:TextService:FilterStringAsync(levelName, levelCreatorId):GetNonChatStringForUserAsync(player.UserId)
. I also don’t want to filter the name and description as if the viewer is the creator of the name and description, because Roblox probably uses logs from these functions for moderation. -
What solutions have you tried so far?
I wasn’t able to find anything related to this on the Developer Hub.
You should filter the level name and description when the player uploads them that way you only need to ever filter each string once.
I thought you were supposed to filter each time it’s retrieved from the data store in case if the filter changes?
According to the API page for FilterStringAsync:
So, in your use case, it is allowed since players can join later or from another server and see the messages.
This is where you’re supposed to use GetNonChatStringForBroadcastAsync. It does not require a specific user to be online in the server and it is intended for global display of text. It accounts for all age groups, privacy settings and whatnot. It is held against the highest level of filtering.
No, you actually should not do this. Two reasons: bad for data management and the filter updates.
The filter is subject to updates and so the string that has previously been filtered may be held against the filter differently, whether words have been whitelisted or blacklisted or the sentence context is adjusted. An improperly filtered sentence is not something you want to have floating in your game.
Saving a filtered string can be detrimental if you’re working with data because then a reference you expect to a certain data set is now nonexistent due to tags. For example, imagine you are working with a specific map name and need to pull that from storage. Oops, can’t anymore, because the lookup expected to return something valid doesn’t do so.
You should always be saving raw strings and filtering text pulled out of a DataStore that comes from user input and is intended to be displayed to other users.
It still needs to be filtered upon retrieval. The TextFilterResult needs made with FilterStringAsync which takes the sender user id (in my case the level creator) as an argument. It also says this:
This method currently throws if fromUserId is not online on the current server. We plan to support users who are offline or on a different server in the future.
Am I missing something? Is there a way to do this properly using GetNonChatStringForBroadcastAsync?
The argument passed for the fromUserId
parameter should be the UserId
of the current player filtering the string, not the player that originally wrote the string that is being filtered.
Okay. But wouldn’t this be an issue still?
This is not an issue as it is intended to work this way.
On the developer hub page for FilterStringAsync, the description of the fromUserId
parameter states “The userId of the player filtering the text.”