Using TextService:FilterStringAsync()

Hi, I’m a bit confused as to how this works. I’m quite new and am still learning, I was following the dev hub thing page and it sort of works, however when I get it to be displayed on the player it just makes them say ‘Instance’. Here is my code.

local rep = game:GetService("ReplicatedStorage")
local re = rep.ArrestSystems:WaitForChild("ReadArrestRights")
local ChatService = game:GetService("Chat")
local TextService = game:GetService("TextService")
local ArrestRights = "You do not have to say anything. But, it may harm your defence if you do not mention when questioned"
local ArrestRights2 = "something which you later rely on in court. Anything you do say may be given in evidence."

re.OnServerEvent:Connect(function(plr, Reason)
	local PlayerChar = plr.Character
	local Head = PlayerChar:FindFirstChild("Head")
	if Reason == nil then
		ChatService:Chat(Head, ArrestRights, Enum.ChatColor.White)
		wait(1)
		ChatService:Chat(Head, ArrestRights2, Enum.ChatColor.White)
	elseif Reason ~= nil then
		local plruserid = plr.UserId
		local FilteredTextReason = TextService:FilterStringAsync(Reason, plruserid)
		ChatService:Chat(Head, FilteredTextReason, Enum.ChatColor.White)
	end
end)

It’s only the bottom section past elseif where I’m doing filtering as the other is a preset message.

Try using the :FilterStringForBroadcast() method instead. (I think it’s recommended for this case as well?)

local filtered = TextService:FilterStringForBroadcast(Reason, plr)

print(filtered)

No, use Chat:FilterStringAsync(Chat, playerfrom,playerfrom)
as FilterStringForBoradcast can’t say any number

I’ve tried this and it doesn’t seem to filter it at all

I’ve noticed string filtering services don’t work in Studio, that might be why.

1 Like