Attempting to make a character name system and having some issues w text filtering

I am trying to make a Character Name System for a game of mine, and I am running into an issue with the Text Filtering, so people don’t have slurs or other stuff as there name,

The main problem is that it filters everything instead of just stuff that would be tagged

SERVER SCRIPT

local Censored = false
local rolled = false
Event2.OnServerEvent:Connect(function(player,Value1,Value2)
	if rolled == true then
		return
	end
	
	local PlayerStats = Stats:FindFirstChild(player.Name)
	
	
	local ts = game:GetService("TextService")
	local text = Value2
	local filteredtext = ts:FilterStringAsync(text,player.UserId):GetNonChatStringForBroadcastAsync()
	
	
	if filteredtext then
		Event2:FireClient(player)
		Censored = true
		return
	end

LOCAL SCRIPT

PlayerNameBox.FocusLost:Connect(function()
	local text = PlayerNameBox.Text
	
	Value2 = text
end)


Frame.Confirm.MouseButton1Up:Connect(function()
	if Value1 == nil then
		return
	end
	
	if Value2 == nil then 
		return 
	end
	
	Event2:FireServer(Value1,Value2)
	
end)

Event2.OnClientEvent:Connect(function()
	Frame.PlayerName.PlaceholderText = "Censored, Please Try again."
	Frame.PlayerName.Text = "Censored, Please Try Again"
end)

GetNonChatStringForBroadcastAsync doesn’t return a bool, it returns the filtered version of the text.
If you wanted to check if it was censored you would see if they are the same string.

if filteredtext == text then
code
end
1 Like

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