Help with TextService:FilterStringAsync

Firing to the remote:

receiving the remote:

no matter what I put, bad word or a normal word, it only prints “instance”

2 Likes

That is because TextService:FilterStringAsync() returns an Instance that contains different parameters for various uses such as age-oriented player demograpics.

This may fix your issue depending on:

-- for a player:
local fullstring = filteredChat:GetChatForUserAsync(plr.UserId)
print(fullstring)
-- for a broadcast:
local fullstring = filteredChat:GetNonChatStringForBroadcastAsync()
print(fullstring)
-- for non-chat text:
local fullstring = filteredChat:GetNonChatStringForUserAsync(plr.UserId)
print(fullstring)

Check out this article for better reference

Also note that text filtering will not work in Studio, and will only work in-game.

Hope this helped!

2 Likes

So this is related to what I’m making at the moment:
https://gyazo.com/1b4907ad5b7e85dbbc03584f81bd33b0
I kind of think I should use broadcast. so should it be

local fullstring = filteredChat:GetChatForBroadcastAsync(message)
print(fullstring)

?

If all players are able to see it, then it would be advised to use GetChatForBroadcastAsync().

You do not need to include the variable message in that specific function.

1 Like

I’m pretty sure that you can’t view chatservice filtered text in studio. If you go in-game and do “/console” in chat, you should be able to see the filtered state of the text.

This applies to all filtering methods I believe.

1 Like

Hmm… sorry for bothering you and I hope it’d be the last one :sweat:

current script

Localscript

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer("bad word")
end)

Server script

local TextService = game:GetService("TextService")

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, message)
local filteredChat = TextService:FilterStringAsync(message, plr.UserId)
local fullstring = filteredChat:GetChatForBroadcastAsync()
print(fullstring)
end)

on studio, it gave me an error so I decided to move onto the real game:

same error in game:

1 Like

No worries. That’s what the DevForum is for.

I see the issue and it was because I didn’t put the full name of the function. It should be:

GetNonChatStringForBroadcastAsync()

My initial reply has also been edited for anyone that may come across this problem down the road.

1 Like

yeesh… roblox and its errors…
and thats my bad I should’ve double checked the article before replying…
Anyway, now I’m getting a new error :sob:

Please send a screenshot of your entire script.


https://gyazo.com/c937356dde7225fa97c0cbf0571d9f95

Remove the extra pair of ()'s at the end of line 5.

Remember that when calling a function, you should only have a single set of parentheses.

1 Like

Yeesh… I’m dumb I really need a habit of proof-reading.
Thank you its now working perfectly :heart:!!
(console prints ####) which is what it was supposed to!

1 Like

Make sure to put it in a pcall in case it doesn’t work.
Check https://developer.roblox.com/en-us/articles/Text-and-Chat-Filtering (Example 2) for more info.