Text Filtering Problem

Hi! I am building a service that can get text from an external website and display it in a Roblox game, but for some reason the Filter Aysnc function seems to not be working. For some reason it filters out all text that is received to hashtags. Here is the serverside code for the Filtering (I don’t think the code is the problem though:

local function fetchChatMessagesFromServer(playerName)
	local player = Players:FindFirstChild(playerName)
	if not player then
		warn("Player not found:", playerName)
		return {}
	end

	local userId = player.UserId
	local url = SERVER_URL .. "/getChatMessages?username=" .. HttpService:UrlEncode(playerName)
	print("Fetching chat messages from server using URL:", url)

	local success, response = pcall(function()
		return HttpService:GetAsync(url)
	end)

	local messagesTable = {}

	if success then
		local fetchedMessages = HttpService:JSONDecode(response)
		print("Received chat messages from server:", fetchedMessages)
		if type(fetchedMessages) == "table" then
			for _, messageData in ipairs(fetchedMessages) do
				local id = tonumber(messageData.id)
				if not id then
					warn("Invalid ID format: " .. tostring(messageData.id))
					continue
				end

				local filteredMessageResult = TextService:FilterStringAsync(messageData.message, userId, Enum.TextFilterContext.PrivateChat)
				local filteredPlayerResult = TextService:FilterStringAsync(messageData.player, userId, Enum.TextFilterContext.PrivateChat)

				local filteredMessage = filteredMessageResult:GetNonChatStringForUserAsync(userId)
				local filteredPlayer = filteredPlayerResult:GetNonChatStringForUserAsync(userId)

				-- Fallback for overly aggressive filtering
				if filteredMessage == "####" then
					filteredMessage = messageData.message
				end

				table.insert(messagesTable, {
					created_at = messageData.created_at,
					id = id,
					message = filteredMessage,
					player = filteredPlayer
				})
			end
		else
			warn("Unexpected response format from server:", fetchedMessages)
		end
	else
		warn("Failed to fetch chat messages from server:", response)
	end

	saveChatMessagesToTable(messagesTable)
	print("Messages table:", messagesTable)
	return messagesTable
end

-- Function to post chat messages to an external server and get the ID
local function postChatMessageToServer(playerName, message)
	local player = Players:FindFirstChild(playerName)
	if not player then
		warn("Player not found:", playerName)
		return nil
	end

	local userId = player.UserId

	-- Filter the message and playerName
	local filteredMessageResult = TextService:FilterStringAsync(message, userId)
	local filteredPlayerResult = TextService:FilterStringAsync(playerName, userId)

	-- Extract filtered text from TextFilterResult
	local filteredMessage = filteredMessageResult:GetNonChatStringForUserAsync(userId)
	local filteredPlayer = filteredPlayerResult:GetNonChatStringForUserAsync(userId)

	local payload = HttpService:JSONEncode({
		player = filteredPlayer,
		message = filteredMessage
	})
	print("Sending chat message to server:", payload)

	local success, result = pcall(function()
		return HttpService:PostAsync(
			SERVER_URL .. "/postChatMessage",
			payload,
			Enum.HttpContentType.ApplicationJson
		)
	end)

	if success then
		print("Successfully posted chat message to server:", result)
		local response = HttpService:JSONDecode(result)
		local newId = response.id -- Extract the ID from the server response
		return newId
	else
		warn("Failed to post chat message to server:", result)
		return nil
	end
end  

In the video is shows how I send the following message “How are you?” and it should be fine to not be filtered. In the console it then it turned into hashtags. It does that for all messages. For a reference here is the code for filtering outgoing and incoming messages: I don’t know if it is something in my code or I am doing something wrong (This is my first ever time using the filtering function.) But if someone could help that would be great. Thanks!

Fixed this problem different one now.