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

What's wrong with this close GUI?

Okay, so I have this script for a close GUI. \

function onClicked()
	Script.parent.parent.parent:Destroy()
end
script.Parent.MouseButton1Click:connect(onClicked)

What is wrong with it? When I click the X box, it doesn't close.

I tried this too, and it doesn't work either:

function onClicked()
	Game.StarterGui.WelcomeGUI:Destroy()
end
script.Parent.MouseButton1Click:connect(onClicked)

3 answers

✓ Accepted answer

I'm not sure if it matters, but you should capitalize parent

script.Parent.Parent.Parent:Destroy()

Also the second one did work, but it destroyed it in StarterGui, not in the playerGui. So it worked, but not in the way you wanted it.

so your final script should be

script.Parent.MouseButton1Click:connect(function()
   script.Parent.Parent.Parent:Destroy()
end)


1 comment

0

Thanks!

In your first example, you haveScript, note that it's capitalized. In your second example, you destroy the StarterGui version of the Gui, not the players, hence you are not affecting the player. Here is a working line to substitute for line two.

script.parent.parent.parent:Destroy()

Instead of destroying it, you can just make it not visible. (So you can edit it a little and make it open again)


And don't capitalize Script, but capitalize Parent

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