Hello, here is a short explanation. So, I want to create a GUI Button for my game that opens a frame when clicked, and when clicked again it makes the same frame invisible,
Here is the script that I made:
-- Variables local clicked = 0 local updateLog = script.Parent.UpdateLogButton local updateLogFrame = script.Parent.Title -- Script updateLog.MouseButton1Click:Connect(function() clicked = clicked + 1 updateLog.MouseButton1Click:Connect(function() if clicked == 1 then updateLogFrame.Visible = true end if clicked == 0 then updateLogFrame.Visible = false end if clicked == 2 or clicked <= 1 then clicked = 0 end end) end)
It seemed to work fine at the start, when I clicked it, it showed the frame and when I clicked it again it made the frame invisible, but when I tried clicking it again (After it made the Frame Invisible.) it did not work ( It didn't make the frame visible again. ). Please help me solve this problem.
function onClick() if (script.Parent.Parent.Parent.updateLogFrame.Visible)then script.Parent.Parent.Parent.updateLogFrame.Visible = false else script.Parent.Parent.Parent.updateLogFrame.Visible = true end end script.Parent.MouseButton1Down:Connect(onClick)
Fix the parents to the amount but this should work accept if so ask help if doesn't
-- Varibles local updateLog = script.Parent.UpdateLogButton local updateLogFrame = script.Parent.Title -- Scripts if updateLog.Text == "Open" then updateLog.MouseButton1Click:Connect(function() updateLogFrame.Visible = true updateLog.Text = "Close" end) end if updateLog.Text == "Close" then updateLog.MouseButton1Click(function() updateLogFrame.Visible = false updateLog.Text = "Open" end) end