Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

3 comments

0

Oooo........

0

I flipped the two and now it works, Thanks :D

0

No problem ;D

This discussion is preserved as it was. New answers, comments, and votes are closed.