Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a GUI Button that when click shows a frame and when clicked again it makes it invisible?

Asked by 5 years ago

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 
03local clicked = 0
04local updateLog = script.Parent.UpdateLogButton
05local updateLogFrame = script.Parent.Title
06 
07-- Script
08 
09updateLog.MouseButton1Click:Connect(function()
10 
11            clicked = clicked + 1
12 
13    updateLog.MouseButton1Click:Connect(function()
14 
15        if clicked == 1 then
View all 35 lines...

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.

2 answers

Log in to vote
0
Answered by 5 years ago
01function onClick()
02 
03if (script.Parent.Parent.Parent.updateLogFrame.Visible)then
04 
05    script.Parent.Parent.Parent.updateLogFrame.Visible = false
06 
07else
08 
09    script.Parent.Parent.Parent.updateLogFrame.Visible = true
10 
11    end
12end
13 
14script.Parent.MouseButton1Down:Connect(onClick)

Fix the parents to the amount but this should work accept if so ask help if doesn't

0
Why is there so many scripts and parents? I don't understand StarzSketchez 31 — 5y
0
Ok So if you have a screengui thats 1 parent if you have a frame in that screengui thats 2 parents so if updatelogframe is in the 2nd frame and you wanna open it you put 3 parents DuckyRobIox 280 — 5y
Ad
Log in to vote
0
Answered by
GITSTP 19
5 years ago
01-- Varibles
02 
03local updateLog = script.Parent.UpdateLogButton
04local updateLogFrame = script.Parent.Title
05 
06-- Scripts
07 
08if updateLog.Text == "Open" then
09    updateLog.MouseButton1Click:Connect(function()
10        updateLogFrame.Visible = true
11        updateLog.Text = "Close"
12    end)
13end
14 
15if updateLog.Text == "Close" then
16    updateLog.MouseButton1Click(function()
17        updateLogFrame.Visible = false
18        updateLog.Text = "Open"
19    end)
20end
0
I think this would work GITSTP 19 — 5y

Answer this question