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

GUI when clicked works, when clicked again it doesn't?

Hello, whenever I click my GUI to show the menu it works by showing the main menu. When I click the GUI again however, everything vanishes and I am unable to click the GUI again. I am unaware of what is causing such problem, as I am very new to scripting. In fact, this isn't my script. Please be aware.

Thanks, Azure.

local open = false
script.Parent.MouseButton1Click:Connect(function()
    if not open then
        open = true
        script.Parent.Parent.Parent.Frame.Visible = true
script.Parent.Parent.Parent.settings.Visible=false
	script.Parent.Parent.Parent.shop.Visible=false
	script.Parent.Parent.Parent.help=false
else
	    script.Parent.Parent.Parent.Frame.Visible = false
	script.Parent.Parent.Parent.settings.Visible=false
	script.Parent.Parent.Parent.shop.Visible=false
	script.Parent.Parent.Parent.help=false
        open = false
    end
end)

1 answer

✓ Accepted answer

this should work:

local open = false

script.Parent.MouseButton1Click:Connect(function() -- fire event when plr clicks
    if not open then -- is the value false?
        open = true -- set value to true
        script.Parent.Parent.Parent.Frame.Visible = true  -- set visible to true
	script.Parent.Parent.Parent.settings.Visible= true
  	script.Parent.Parent.Parent.shop.Visible=true
  	script.Parent.Parent.Parent.help.Visible =true
else
        open = false -- set value to false
   	script.Parent.Parent.Parent.Frame.Visible = false -- set visible to false
        script.Parent.Parent.Parent.settings.Visible=false
  	script.Parent.Parent.Parent.shop.Visible=false
    	script.Parent.Parent.Parent.help.Visible=false
    end
end)

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