Why isn't my textfilter working?

Realized today that you need to manually censor textbox text using code and I’ve read and reread the documentation a couple times and this code still will not work:

What am I doing wrong? I heard you cant test in studio but even if I join a real server it wont work.

TitleChangedEvent.OnServerEvent:Connect(function(Player, Text)

local TitleName = Player:WaitForChild("TierListTitle")

local filteredTextResult


local success, errorMessage = pcall(function()
	filteredTextResult = TextService:FilterStringAsync(Text, Player.UserId)
	
end)

if not success then
	warn("Error filtering text:", Text, ":", errorMessage)
	-- Put code here to handle filter failure
end

if success then
	TitleName.Value = Text
end

end)

Looking at your code it seems like you set the original text as the title name instead of the censored one. Try changing TitleName.Value = Text into TitleName.Value = filteredTextResult.

1 Like

You were correct. Here is the complete code:
I had to add a “Getnonchatstringforbroadcastasync” thing as well

TitleChangedEvent.OnServerEvent:Connect(function(Player, Text)

local TitleName = Player:WaitForChild("TierListTitle")

local filteredTextResult


local success, errorMessage = pcall(function()
	filteredTextResult = TextService:FilterStringAsync(Text, Player.UserId)
	
end)

local Newtext = filteredTextResult:GetNonChatStringForBroadcastAsync()

if not success then
	warn("Error filtering text:", Text, ":", errorMessage)
	-- Put code here to handle filter failure
end

if success then
	TitleName.Value = Newtext
end

end)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.