Help with Filtering Text

This is my first time messing around with filtering strings and I need some help to figure out things.

I tried reading the Wiki page but it was a little bit confusing, I blame that on myself since I’ve been quite tired.

If anyone could explain to me why this is not working
[Testing in Studio]

game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)

local filterMsg = game:GetService('Chat'):FilterStringAsync(msg, player, game.Players.Player2)

print(filterMsg)

	end)
end)

When I chat in-game, as Player1, and I say a bad word, it prints it the bad word instead of it getting filtered.

1 Like

I have used this before maybe give it a try?

local filteredmsg = game:GetService("Chat"):FilterStringForBroadcast(msg, player)
1 Like

I tried using :FilterStringForBroadcast() but it didn’t work, I’ll try once more and provide errors, if any.

1 Like

Alright, I just changed it to :FilterStringForBroadcast() and it still prints out the bad word, not filtered.

1 Like

Hmmm, I have used :FilterStringForBroadcast() but just in a LocalScript so that might be it.

1 Like

Let me try using it on a LocalScript.

Filtering doesn’t work in studio, test it in a live game

2 Likes

Oh, that seems to be the problem. Thanks for helping. I tested it in-game and it’s filtering just fine.