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

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

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?

2 comments

0

Any more information you could provide?

0

Try using a textbutton

2 answers

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?

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.

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