Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Click Again to Reverse Code
- smisamul6
-
Scratcher
100+ posts
Click Again to Reverse Code
How do I make a script where I can click again on a button to reverse it? For example, I am making a Windows 11 Emulator. When you click the Windows icon on the bottom of the screen, it brings up the menu. I want to be able to click again to make the menu go. How do I do that? Please help somebody. Thanks in advance! 
Edit: It worked! Credit to @RadiusGames46

Edit: It worked! Credit to @RadiusGames46
Last edited by smisamul6 (March 6, 2023 03:31:34)
- medians
-
Scratcher
1000+ posts
Click Again to Reverse Code
Just use an if statement to detect if the menu is open or not.
- smisamul6
-
Scratcher
100+ posts
Click Again to Reverse Code
Just use an if statement to detect if the menu is open or not.How do I do that?
- RadiusGames46
-
Scratcher
100+ posts
Click Again to Reverse Code
Simple.Just use an if statement to detect if the menu is open or not.How do I do that?
Just make a variable called “Menu Open” or something, and then add the following code:
when gf clicked
set [Menu Open v] to [0]
. . . :: hat grey // Add whatever is used to sense the click here.
if <(Menu Open) = [0]> then
. . . // Put whatever happens when you open the menu here.
set [Menu Open v] to [1]
else
. . . // Put whatever happens when you close the menu here.
set [Menu Open v] to [0]
- medians
-
Scratcher
1000+ posts
Click Again to Reverse Code
You can use a variable to check when it's clicked.Just use an if statement to detect if the menu is open or not.How do I do that?
Or instead, you could have a blank costume on the start menu instead, and check what costume it is using this code:


The blank costume is the closed one.
- smisamul6
-
Scratcher
100+ posts
Click Again to Reverse Code
I am using the ghost effect block. I am not doing costumes.You can use a variable to check when it's clicked.Just use an if statement to detect if the menu is open or not.How do I do that?
Or instead, you could have a blank costume on the start menu instead, and check what costume it is using this code:
The blank costume is the closed one.
- smisamul6
-
Scratcher
100+ posts
Click Again to Reverse Code
Simple.Just use an if statement to detect if the menu is open or not.How do I do that?
Just make a variable called “Menu Open” or something, and then add the following code:when gf clicked
set [Menu Open v] to [0]
. . . :: hat grey // Add whatever is used to sense the click here.
if <(Menu Open) = [0]> then
. . . // Put whatever happens when you open the menu here.
set [Menu Open v] to [1]
else
. . . // Put whatever happens when you close the menu here.
set [Menu Open v] to [0][/quote]
I will try that.
- smisamul6
-
Scratcher
100+ posts
Click Again to Reverse Code
Simple.Just use an if statement to detect if the menu is open or not.How do I do that?
Just make a variable called “Menu Open” or something, and then add the following code:when gf clicked
set [Menu Open v] to [0]
. . . :: hat grey // Add whatever is used to sense the click here.
if <(Menu Open) = [0]> then
. . . // Put whatever happens when you open the menu here.
set [Menu Open v] to [1]
else
. . . // Put whatever happens when you close the menu here.
set [Menu Open v] to [0][/quote]
Thanks so much!! It worked!!
- Discussion Forums
- » Help with Scripts
-
» Click Again to Reverse Code