FilterStringAsync Returning Blank

I have a custom chat in my game but when I send a message and run it through the filter it just returns blank when this was just working yesterday.
Code:

textservice = game:GetService("TextService")
receivechatmessage = game.ReplicatedStorage:WaitForChild("events"):WaitForChild("ReceiveChatMessage")

function SendMessage(player, text)
	local filtered = nil
	
	print(text)
	
	local success, errorMessage = pcall(function()
		filtered = textservice:FilterStringAsync(text, player.UserId, Enum.TextFilterContext.PublicChat)
	end)
	
	if success then
		for i,v in pairs(game.Players:GetPlayers()) do
			local filteredforplayer = nil
			
			local success2, errorMessage2 = pcall(function()
				filteredforplayer = textservice:FilterStringAsync(text, player.UserId, Enum.TextFilterContext.PublicChat)
			end)
			if success2 then
				local filteredforplayer = filtered:GetChatForUserAsync(player.UserId, Enum.TextFilterContext.PublicChat)
				print(filteredforplayer)
				receivechatmessage:FireClient(v, player.Name, filteredforplayer)
			else
				warn("Error filtering text:", text, ":", errorMessage2)
			end
		end
		
	else
		warn("Error filtering text:", text, ":", errorMessage)
	end
end

game.ReplicatedStorage.events.SendChatMessage.OnServerEvent:Connect(SendMessage)

Any idea why this happened?
Examples and fixed versions will be appreciated!

Fixed! I had to switch filtered:GetChatForUserAsync(player.UserId, Enum.TextFilterContext.PublicChat) with filtered:GetNonChatStringForUserAsync(player.UserId).

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