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

What's wrong with this close GUI?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)


0
Thanks! Antharaziia 75 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

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()
Log in to vote
1
Answered by 9 years ago

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

Answer this question