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

My gui opening and closing doesn't work?

Asked by
Relatch 550 Moderation Voter
8 years ago

I basically want my gui to open and close. But, I also want it to check if another gui's button is visible, meaning it's open as well. If it is open, it closes that and then opens the gui. But, that doesn't work so well. I get no errors, it just doesn't open.

function clicked()
    local playing = script.Parent.Parent.Parent.Parent.playing
    local debounce = false
    if script.Parent.Parent.Shop.Visible == true and debounce == false then
        debounce = true
        script.Parent.Parent.Shop.Visible = false
        script.Parent.Parent.Shop.Active = false
        wait(1)
    elseif script.Parent.Parent.Shop.Visible == false and debounce == false then
        if script.Parent.Parent.Parent.GameInfo.Shop.Visible == true then
            debounce = true
            script.Parent.Parent.Shop.Visible = true
            script.Parent.Parent.Shop.Active = true
            script.Parent.Parent.Parent.GameInfo.Shop.Visible = false
            script.Parent.Parent.Parent.GameInfo.Shop.Active = false
            wait(1)
        elseif script.Parent.Parent.Parent.GameInfo.Shop.Visible == true then
            debounce = true
            script.Parent.Parent.Shop.Visible = true
            script.Parent.Parent.Shop.Active = true
            wait(1)
        end
    end
    wait()
end

script.Parent.MouseButton1Down:connect(clicked)

Help?

0
just a coding tip, you dont need things like "Visible == true" as an if statment will run if true anyway. use "if Visible then" its a lot faster User#5423 17 — 8y
0
Do you have an error in the output? Because that would really help. rollercoaster57 65 — 8y
0
Then I am stumped. rollercoaster57 65 — 8y
0
I have an idea, perhaps you can us onClicked? on the top and number 27 should be MouseButton1Click:connect(onClicked) a GreekGodOfMLG 244 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Seriously, way to complicated.

 local debounce = false --just good practice to put this out of the function
function clicked()
    if debounce == false then
        debounce = true -- this way no matter what it goes to true
    if script.Parent.Parent.Shop.Visible then
        script.Parent.Parent.Shop.Visible = false
        wait(1)
    elseif script.Parent.Parent.Shop.Visible == false then
        if script.Parent.Parent.Parent.GameInfo.Shop.Visible == true then
            script.Parent.Parent.Shop.Visible = true
            script.Parent.Parent.Parent.GameInfo.Shop.Visible = false
            wait(1)
        end
end
debounce = false
    end
    wait()
end
script.Parent.MouseButton1Down:connect(clicked)

It was simple, you just made it so overly complicated. You do not have to recheck if debounce is false each time, only once. I am not quite sure what else you wanted because that code was so jumbled and I had a hard time figuring out what was what. Remember, keep it simple, I don't think any of my code goes over 100 lines ever.

0
Doesn't work. Relatch 550 — 8y
0
No, I don't. Relatch 550 — 8y
Ad

Answer this question