My goal : I am trying to make a script that opens a window when you click a GUI button the closes that window if it is visible when the button is clicked again. The problem: when i click the button again and again it just keeps printing level 1 complete and stops there it also opens the window., i get no errors in the output to.
a=script.Parent.Parent.Frame b=script.Parent.Parent.Frame.VoteText script.Parent.MouseButton1Click:connect(function() a.Visible=true b.Visible=true print("level 1 complete") end) function onClicked() a.Visible=false b.Visible=false print("level 3 complete") end if a.Visible==true and b.Visible==true then script.Parent.MouseButton1Click:connect(onClicked) print ("level 2 complete") else print("you failed") return end