Why does the filter text return blank?

I’ve been making a note system for my game where players can write notes but i need to add a system to filter their text. why does the “cleantext” variable print blank?

local textService = game:GetService("TextService")
local remoteEventsFolder = game.ReplicatedStorage.RemoteEvents

local filterRequest = remoteEventsFolder.FilterText

local function getFilteredText(text, playerFromId)
	local filterResult
	local success, errorMessage = pcall(function()
		filterResult = textService:FilterStringAsync(text, playerFromId)
	end)
	
	if success then
		return filterResult:GetChatForUserAsync(playerFromId)
	else
		warn("Error filtering text: ".. errorMessage)
		return "###"
	end
end

filterRequest.OnServerEvent:Connect(function(player, rawtext)
	local cleanText = getFilteredText(rawtext, player.UserId)
	
	print("Filtered text is: " .. cleanText)
	filterRequest:FireClient(player, cleanText)
end)

Thats because GetChatForUserAsync() has been replaced.

I got this error when i tried your script in studio:

GetChatForUserAsync is being deprecated. Use TextChatService instead which automatically filters text sent.

Instead replace

return filterResult:GetChatForUserAsync(playerFromId)

with

return filterResult:GetNonChatStringForUserAsync(playerFromId)

Thank youuuuu, this works noww