Message Filitering

EDIT: Turns out the filter wasn’t functioning properly in studio, but works fine in-game. Thanks for the help!

I’m trying to make a system for players to display messages to the server when they donate a certain amount of Robux. For some reason, even obviously filtered words are passing through as accepted and being displayed. I’ve tried using filtering systems from other posts and modules, but nothing is working.

ClientEvent.OnServerEvent:Connect(function(player, action, message, amount)
	if action == "FilterMessage" then
		local success, result
		local TextService = game:GetService("TextService")

		success, result = pcall(function()
			return TextService:FilterStringAsync(message, player.UserId)
		end)

		if success then
			local filteredText = result:GetNonChatStringForBroadcastAsync()

			if filteredText == "" or filteredText:match("^%*+$") then
				ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
			else
				ClientEvent:FireClient(player, "FilterResult", "Accepted", amount)
				NotifEvent:FireAllClients("server", filteredText, player, amount)
			end
		else
			warn("Filtering failed:", result)
			ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
		end
	end
end)

Change this:

ClientEvent.OnServerEvent:Connect(function(player, action, message, amount)
	if action == "FilterMessage" then
		local success, result
		local TextService = game:GetService("TextService")

		success, result = pcall(function()
			return TextService:FilterStringAsync(message, player.UserId)
		end)

		if success then
			local filteredText = result:GetNonChatStringForBroadcastAsync()

			if filteredText == "" or filteredText:match("^%*+$") then
				ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
			else
				ClientEvent:FireClient(player, "FilterResult", "Accepted", amount)
				NotifEvent:FireAllClients("server", filteredText, player, amount)
			end
		else
			warn("Filtering failed:", result)
			ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
		end
	end
end)

to this:

ClientEvent.OnServerEvent:Connect(function(player, action, message, amount)
	if action == "FilterMessage" then
		local success, result
		local TextService = game:GetService("TextService")

		success, result = pcall(function()
			return TextService:FilterStringAsync(message, player.UserId)
		end)

		if success then
			local filteredText = result:GetNonChatStringForBroadcastAsync()

			if filteredText == "" or filteredText:match("^%*+$") then
				print("Text has been filtered.")
				ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
			else
				print("Text has not been filtered.")
				ClientEvent:FireClient(player, "FilterResult", "Accepted", amount)
				NotifEvent:FireAllClients("server", filteredText, player, amount)
			end
		else
			warn("Filtering failed:", result)
			ClientEvent:FireClient(player, "FilterResult", "Filtered", amount)
		end
	end
end)

and check the developer console. Does it say “filtered” or “not filtered”?

Hey, I tried this and it’s printing that the text has not been filtered. I tried with profanity and just “test” but neither got filtered.

100% sure Roblox just allows profanity now

but don’t even THINK about saying hello… OH NO

Both FilterStringAsync and GetNonChatStringForBroadcastAsync are deprecated and will return an empty string. While It’s not exactly recommended, the only way to display a message with a filter is using GetNonChatStringForBroadcastAsync