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

Why doesn't my gui disappear when i click it?

Asked by 8 years ago
bin = script.Parent  

function Clicked()  
bin.Parent.Visible = false  
script.Parent.Parent.Visible = false
local Main = script.Parent.Parent.Parent:findFirstChild("Main")
Main.Visible = true

end 
bin.MouseButton1Down:connect(Clicked)

Any suggestions?

0
Any more information you could provide? M39a9am3R 3210 — 8y
0
Try using a textbutton DevingDev 346 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Try using it as a Local script. They are much easier to use when doing stuff with UI. Also, is this a StarterGUI that pops up when you join?

Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago
bin = script.Parent 

function Clicked()  
bin.Parent.Visible = false  


script.Parent.Parent.Visible = false 
--^ Why? bin.Parent is the same as script.Parent.Parent!

local Main = script.Parent.Parent.Parent:FindFirstChild("Main") 

--^ If the 'Main' is the same as script.Parent.Parent then it's the next line just makes the bin.Parent.Parent AKA 'Main' visible again.

Main.Visible = true

--^ Remove this, if script.Parent.Parent is 'Main'.

end 

bin.MouseButton1Down:connect(Clicked)

I'd rather do it like this;

local Visible = false

script.Parent:MouseButton1Down:connect(function()
if Visible == true then
    Visible = false
    script.Parent.Parent.Visible = false
elseif Visible == false then
    Visible = true
    script.Parent.Parent.Visible = true
end)

The local 'Visible' is because you could use some later on checks to see if the GUI is actually closed or opened.

Answer this question