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?
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.