I tried this, when the player doesn't exist, it prints that the player doesn't exist, but when the player does exist, it also prints that the player does not exist, how could i fix this?
01 | local text = script.Parent.Text |
02 | local Players = game:GetService( "Players" ) |
03 | script.Parent.FocusLost:Connect( function (enterPressed) |
04 | if enterPressed then |
05 | if not Players:FindFirstChild(text) then |
06 | print ( "Player " ..script.Parent.Text.. " does not exist." ) |
07 | return end |
08 | else |
09 | print (script.Parent.Text) |
10 | script.Parent.name.Value = script.Parent.Text |
11 | script.Parent.Visible = false |
12 | script.Parent.Parent.valueedit.Visible = true |
13 | end |
14 | end ) |
01 | local Players = game:GetService( "Players" ) |
02 | script.Parent.FocusLost:Connect( |
03 | function (enterPressed) |
04 | if enterPressed then |
05 | local text = script.Parent |
06 | for _, player in pairs (Players:GetPlayers()) do |
07 | if not text.Text = = player.Name then |
08 | print ( "Player " .. script.Parent.Text .. " does not exist." ) |
09 | return |
10 | else |
11 | print (script.Parent.Text) |
12 | script.Parent.name.Value = script.Parent.Text |
13 | script.Parent.Visible = false |
14 | script.Parent.Parent.valueedit.Visible = true |
15 | end |
16 | end |
17 | end |
18 | end |
19 | ) |
Figured it out guys, had to put local text = script.Parent.Text after the focus lost.