I am making a textbox where the player can determine a name for their new character in the game. However, I need to filter the text and I am not too sure how to do that. I have put the script in but it never filters the text, no matter what I type it always goes through.

local player = script.Parent.Parent.Parent.Parent.Parent
local fromPlayerId = player.UserId

local text = script.Parent.Parent.NameBox
local TextService = game:GetService("TextService")
local filteredTextResult = TextService:FilterStringAsync(text, fromPlayerId)

script.Parent.MouseButton1Down:Connect(function()
	local TextService = game:GetService("TextService")
	local filteredText = ""
	local success, errorMessage = pcall(function()
		filteredTextResult = TextService:FilterStringAsync(text, fromPlayerId)
		game.Workspace.UIsounds.ClickMenuOk:Play()
		script.Parent.Parent.Parent.Frame.Visible = false
		script.Parent.Parent.Parent.Parent.EndPrompt.Frame.Visible = true
	end)
	if not success then
		game.Workspace.UIsounds.Error:Play()
		script.Parent.Parent.Parent.Parent.EndPrompt.UnsuccessFrame.Visible = true
		script.Parent.Parent.Visible = false
		-- Put code here to handle filter failure
	end
end)

3 comments

0

Try it in Main Game. Text Filters doesn't work in studio.

0

Ok thanks!

0

Nope, still won't work