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:
01 | -- Variables |
02 |
03 | local clicked = 0 |
04 | local updateLog = script.Parent.UpdateLogButton |
05 | local updateLogFrame = script.Parent.Title |
06 |
07 | -- Script |
08 |
09 | updateLog.MouseButton 1 Click:Connect( function () |
10 |
11 | clicked = clicked + 1 |
12 |
13 | updateLog.MouseButton 1 Click:Connect( function () |
14 |
15 | if clicked = = 1 then |
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.
01 | function onClick() |
02 |
03 | if (script.Parent.Parent.Parent.updateLogFrame.Visible) then |
04 |
05 | script.Parent.Parent.Parent.updateLogFrame.Visible = false |
06 |
07 | else |
08 |
09 | script.Parent.Parent.Parent.updateLogFrame.Visible = true |
10 |
11 | end |
12 | end |
13 |
14 | script.Parent.MouseButton 1 Down:Connect(onClick) |
Fix the parents to the amount but this should work accept if so ask help if doesn't
01 | -- Varibles |
02 |
03 | local updateLog = script.Parent.UpdateLogButton |
04 | local updateLogFrame = script.Parent.Title |
05 |
06 | -- Scripts |
07 |
08 | if updateLog.Text = = "Open" then |
09 | updateLog.MouseButton 1 Click:Connect( function () |
10 | updateLogFrame.Visible = true |
11 | updateLog.Text = "Close" |
12 | end ) |
13 | end |
14 |
15 | if updateLog.Text = = "Close" then |
16 | updateLog.MouseButton 1 Click( function () |
17 | updateLogFrame.Visible = false |
18 | updateLog.Text = "Open" |
19 | end ) |
20 | end |