Hello! I was recently making a character customization system and there you can change your character name and have it above your head in a Billboard Gui, so I was trying to filter every string the player types in a specific TextBox, but the problem is that the text is not getting filtered, I tried searching all over the DevForum and DeveloperHub and I found nothing that can fix that.
Local Script:
NameBox:GetPropertyChangedSignal("Text"):Connect(function()
NameValue.Value = NameBox.Text
NameChangedRE:FireServer(NameValue.Value,NameValue)
end)
Server Script:
NameChangedRE.OnServerEvent:Connect(function(player,text,nameVal)
local headGui = player.Character.HumanoidRootPart.NameGui
local notification = player.PlayerGui:WaitForChild("CustomizationGui").Notification
if string.match(text,"%d+") or string.match(text,"%p+") or string.match(text,"%d+%p+") then
notification.Text = "You can't have special characters or numbers in your name!"
notification.Visible = true
wait(3)
if notification.Visible == true then
notification.Visible = false
end
else
if text ~= "" then
local newText
local filteredString
local success, errorMsg = pcall(function()
newText = TextService:FilterStringAsync(text,player.UserId)
end)
local filtered, unFiltered = pcall(function()
filteredString = newText:GetNonChatStringForBroadcastAsync(player.UserId)
end)
if success and filteredString then
nameVal.Value = filteredString
headGui.TextLabel.Text = filteredString
else
notification.Text = "You can't use an inappropriate name!"
notification.Visible = true
wait(3)
if notification.Visible == true then
notification.Visible = false
end
end
else
nameVal.Value = ""
headGui.TextLabel.Text = ""
end
end
end)