Need help w a censorship name

Been looking around and haven’t been able to find anything that helps me,

FilteredText keeps returning nil.

Events.OCName.OnServerEvent:Connect(function(player,text)
	print("Worked")
	local Overhead = player.Character:FindFirstChild("Head").Overhead.OC
	
	
	print(text)
	local filteredText = ""
	local success, errorMessage = pcall(function()
		local filteredTextResult = TextService:FilterStringAsync(text, player.UserId)
		print(filteredTextResult)
	end)
	if not success then
		warn("Error filtering text:", text, ":", errorMessage)
		Overhead.Text = "Censored."
	elseif success then
		print(filteredText)
		Overhead.Text = filteredText
	end
end)

Well that is because your Not filtering correctly. When using TextService:FilterStringAsync() It returns a TextFilterResult and NOT a string. You need to Pair it with a TextFilterResult:GetNonChatStringForBroadcastAsync() or TextFilterResult:GetNonChatStringForUserAsync() Which does the real filtering in your filter, and returns a string to be used


Difference between the two include (from roblox docs):


You can read more about it here on the Roblox Docs!

(P.S. Text filtering doesn’t work in studio. In order to test it, publish your changes and hop into the Roblox appilication)

2 Likes

What does that print? It’s nil?

Are you in studio when testing?

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