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

My gui opening and closing doesn't work?

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?

4 comments

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

0

Do you have an error in the output? Because that would really help.

0

Then I am stumped.

0

I have an idea, perhaps you can us onClicked? on the top and number 27 should be MouseButton1Click:connect(onClicked) a

1 answer

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.

2 comments

0

Doesn't work.

0

No, I don't.

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