How to prevent bypass?

My script is now

local result = ChatService:FilterStringAsync(Messages, Player.UserId, Enum.TextFilterContext.PublicChat)
local chatMessage = result:GetChatForUserAsync(game.Players) -- no clue how to call this from a ServerScript

If it does not work either, send us a screenshot of the error at the Output.

Because :GetChildren returns an array of player instances. You need to get the user ID of a specific player.


You need to pass in a single player, your script is using a table of players. Also since this is text that is being shown to everyone you might want to use TextFilterResult:GetNonChatStringForBroadcastAsync( ) since that applies the filter in a more strict manner for all users.

Here is a reply I made in an older post on how to use the filter:

I tried this type of code:

ChatService:FilterStringAsync(Player.Id, Messages)
TextFilterResult:GetNonChatStringForBroadcastAsync() -- how can I define this?

The global is not defined here.

local tfResult = game:GetService("TextService"):FilterStringAsync(message, player.UserId)
local filteredText = tfResult:GetNonChatStringForBroadcastAsync()

Testing in-game, I still was able to bypass is there anything wrong with my script?

ChatService = game:GetService("Chat")

	local tfResult = game:GetService("TextService"):FilterStringAsync(Messages, Player.UserId)
	local filteredText = tfResult:GetNonChatStringForBroadcastAsync()

It depends, are you sure that filteredText is what you are putting in the chat bubble? Just defining the variable won’t do anything.

From that code that is it, should I add a if statement like:

local FilteredStr = pcall(TextService.FilterStringAsync, TextService, Messages, Player.UserId, Enum.TextFilterContext.PublicChat) 
if filteredText then
		return FilteredStr:GetChatForUserAsync(Player.UserId)
		return ""

No, you just need to use filteredText as the message when you make the NPCs chat.

Odd, what could be the issue then?

Can you post the code that makes the bots appear and talk as you mentioned in the first post?

Sent on Direct Messages. @Blokav

Alright, I see the issue it looks like you’re still using the Messages and not the filtered text.

Try using this:

for index, text in ipairs(Messages) do
	local tfResult = game:GetService("TextService"):FilterStringAsync(text, Player.UserId)
	local filteredText = tfResult:GetNonChatStringForBroadcastAsync()
	Messages[index] = filteredText

This will replace the text in the Messages array with their filtered values.

1 Like

Tysm! I needed this quite badly!

@reteyetet Cheers, thank you so much! :smile:

1 Like

Please keep this thread on-topic. What you guys are responding right now is not related to the topic at all.
I also want to remind you guys of the Forum Rules.