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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Hydrogyn 155
4 years ago

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)
Ad

Answer this question