I have a click open/close button that opens a frame. Problem is when you click "Close" the frame dosent close. What is the problem and how to fix it?
Box = script.Parent.Box Button = script.Parent.Button Open = false Button.MouseButton1Down:connect(function(open) if Open == false then Button.Text = "Close" Box.Visible = true elseif Open == true then Button.Text = "Information" Box.Visible = false end end)
Box is the frame, Button is the open/close button
You are not setting your variable Open
between true and false. Therefore, the first condition (opening the frame) will always be the one that runs.
Box = script.Parent.Box Button = script.Parent.Button Open = false Button.MouseButton1Down:connect(function() if Open == false then Button.Text = "Close" Box.Visible = true Open = true --Set it to true here. elseif Open == true then Button.Text = "Information" Box.Visible = false Open = false --Set it to false here. end end)
If I helped you out, be sure to accept my answer!
You don't have to put "Open" in the function perimeters, you are connecting the function with MouseButton1Down. Open is also a global variable so you can use it or change it anywhere (even inside functions).