Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to close to close a GUI and open another but I keep getting a nil value?

Asked by 7 years ago
Edited 7 years ago

I have a free modeled password script. (I was to lazy to make one. Its for a game I am making just for my friends) Line 15 is my script I put in to make my skin color change GUI show up. Here is script ~~~~~~~~~~~~~~~~~

local box = script.Parent.Parent:WaitForChild('TextBox') local button = script.Parent local code = 'p0tat0' local tries = 0 local maxtries = 3 button.MouseButton1Click:connect(function() if tries == maxtries then game.Players.LocalPlayer:Kick() else

if box.Text == code then
    button.Text = 'Password accepted - loading game'
    wait(2)
    script.Parent.Parent.Parent:Destroy()
    script.Parent.Parent.Parent.Parent.ColorChange.Frame.Visible = true
else
    button.Text = 'Incorrect password - '..maxtries - tries..' tries left'
    tries = tries + 1
end
    end

end) ~~~~~~~~~~~~~~~~~ (Idk why the variables and start of function aren't showing up as script) When I type in the password the GUI doesn't show up and I get this in the output: "18:20:41.920 - Players.Player1.PlayerGui.PassGUI.Frame.TextButton.LocalScript:15: attempt to index field 'Parent' (a nil value)"

Any Ideas?

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

You run script.Parent.Parent.Parent:Destroy() wich means you'd destroy everything inside of script.Parent.Parent.Parent including the script itself. dingus

0
Oooo........ User#15461 0 — 7y
0
I flipped the two and now it works, Thanks :D User#15461 0 — 7y
0
No problem ;D RubenKan 3615 — 7y
Ad

Answer this question