Expanding upon the previous answer, there are two functions which are important: FilterStringAsync
and FilterStringForBroadcast
. They both function very similarly, but with slightly different parameters. They are both members of the Chat
service.
FilterStringAsync
has three parameters:
- The first is simply the string to be filtered.
- The second is the player who is sending the message.
- The third is the player who is receiving the message.
However, if you don't know (or care) who the message is being sent to, as is likely the case with your chat system, you may prefer FilterStringForBroadcast
. It is similar to the previous function, but with only two arguments: the string to be filtered, and the player sending the message. The idea is that the string returned by it will be acceptable for anyone to see regardless of their chat settings.
More information on these functions can be found here.
Hopefully this is what you are looking for.
Also, apologies for going a bit off-topic, but I noticed this code here:
2 | for i,v in pairs (storage:GetChildren()) do |
This code looks like it could be implemented in a better way. I would suggest looking into the Debris service.