I am trying to filter text as the game lets players choose a name for there characters, and I keep running into an error with it, attempt to index string with ‘Value’
Event2.OnServerEvent:Connect(function(player,Value1,Value2)
if rolled == true then
return
end
local PlayerStats = Stats:FindFirstChild(player.Name)
local text = Value2
local filteredText = ""
local success, errorMessage = pcall(function()
Value2.Value = TextService:FilterStringAsync(text, player.UserId):GetNonChatStringForBroadcastAsync()
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
print("try again lil bro")
Event2:FireClient(player)
return
end
now its printing nil whenever i print text, perhaps the local script will help u too
lua
local Value1 = nil
local Value2 = nil
MaleButton.MouseButton1Click:Connect(function()
Value1 = true
end)
FemaleButton.MouseButton1Up:Connect(function()
Value1 = false
end)
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."
end)