3 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

Text filtering

Applied to various sources and inputs, text filtering prevents users from seeing inappropriate language and personally identifiable information such as phone numbers. Roblox automatically filters common text outputs such as messages that have passed through in-game text chat, but you are responsible for filtering any displayed text that you don't have explicit control over.

Note

Because filtering is crucial for a safe environment, Roblox actively moderates the content of games to make sure they meet community standards. If Roblox receives reports or automatically detects that your game doesn't apply text filtering, then the system removes the game until you add filtering.

Filter scenarios

Text can be gathered and/or displayed to users in a variety of scenarios, including:

Filtering process

TextService:FilterStringAsync() filters in-game text by taking a string of text and the UserId of the user who created the text as input. It returns a TextFilterResult object which has two additional methods that you can call in different scenarios:

In the context of TextBox input, the following example gathers input on the FocusLost event and sends it to the server through a RemoteEvent. On the server, it is filtered first through FilterStringAsync() and then GetNonChatStringForBroadcastAsync() with the intention that the text will be displayed to all users on a server‑side object such as a SurfaceGui in the 3D world.

Note

Do not filter text in real time "per character entered" into a TextBox, as doing so yields for text that's only visible to the user typing it. Instead, filter the entered text after the user submits it.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local textBox = script.Parent
textBox.ClearTextOnFocus = false
textBox.PlaceholderText = "..."
textBox.TextXAlignment = Enum.TextXAlignment.Left
textBox.TextScaled = true

-- RemoteEvent to send text input to server for filtering
local inputRemoteEvent = ReplicatedStorage:FindFirstChild("InputRemoteEvent")

-- Event handler for focus lost and enter being pressed
local function onFocusLost(enterPressed, inputObject)
	if enterPressed then
		print("SUBMITTED:", textBox.Text)
		if inputRemoteEvent then
			inputRemoteEvent:FireServer(textBox.Text)
		end
	end
end

textBox.FocusLost:Connect(onFocusLost)
local TextService = game:GetService("TextService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- RemoteEvent to receive text input from client for filtering
local inputRemoteEvent = ReplicatedStorage:FindFirstChild("InputRemoteEvent")

local function getFilterResult(text, fromUserId)
	local filterResult
	local success, errorMessage = pcall(function()
		filterResult = TextService:FilterStringAsync(text, fromUserId)
	end)

	if success then
		return filterResult
	else
		warn("Error generating TextFilterResult:", errorMessage)
	end
end

-- Fired when client submits input from the TextBox
local function onInputReceived(player, text)
	if text ~= "" then
		local filterResult = getFilterResult(text, player.UserId)
		if filterResult then
			local success, filteredText = pcall(function()
				return filterResult:GetNonChatStringForBroadcastAsync()
			end)

			if success then
				print("FILTERED:", filteredText)
			else
				warn("Error filtering text!")
			end
		end
	end
end

inputRemoteEvent.OnServerEvent:Connect(onInputReceived)