Discuss Scratch

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

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

medians wrote:

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

smisamul6 wrote:

medians wrote:

Just use an if statement to detect if the menu is open or not.
How do I do that?
Simple.

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

smisamul6 wrote:

medians wrote:

Just use an if statement to detect if the menu is open or not.
How do I do that?
You can use a variable to check when it's clicked.
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

medians wrote:

smisamul6 wrote:

medians wrote:

Just use an if statement to detect if the menu is open or not.
How do I do that?
You can use a variable to check when it's clicked.
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.
I am using the ghost effect block. I am not doing costumes.
smisamul6
Scratcher
100+ posts

Click Again to Reverse Code

RadiusGames46 wrote:

smisamul6 wrote:

medians wrote:

Just use an if statement to detect if the menu is open or not.
How do I do that?
Simple.

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

RadiusGames46 wrote:

smisamul6 wrote:

medians wrote:

Just use an if statement to detect if the menu is open or not.
How do I do that?
Simple.

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!!

Powered by DjangoBB