This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
For thread safety, this property is not safe to read in an unsynchronized thread.
Filters a string sent from playerFrom for broadcast to no particular target. The filtered message has more restrictions than
Some examples of where this method could be used:
- -Message walls
- -Cross-server shouts
- -User-created signs
Calling FilterString from
LocalScripts is deprecated and will be disabled in the future. Text filtering should be done from server-side
Scripts using FilterStringAsync.
Note: A game not using this filter function for custom chat or other user generated text may be subjected to moderation action.
Message string being filtered
Instance of the player sending the message
Filtered message string
The following example shows a simple way to use the FilterStringForBroadcast function. The example uses the message variable as the stringToFilter argument and the local player as the playerFrom argument.
The example then prints the result of the filtering function, FilteredString.
local playerFrom = game.Players.LocalPlayer -- Local player (player sending message) local message = "Hello world!" -- Message to be filtered -- Filter the string and store the result in the 'FilteredString' variable FilteredString = game:GetService("Chat"):FilterStringForBroadcast(message, playerFrom) -- Print the filtered string print(FilteredString)