Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make pause button
- Tornisterz
-
Scratcher
13 posts
How to make pause button
Help me guys! how do I make a pause button? need help for my new project, also im new here, check out me games, most of them are 1 day builds
- nerdloop330
-
Scratcher
100+ posts
How to make pause button
That depends on what your project is about. An easy way to make a pause function is to use this code frequently:
That way, you can pause the project whenever you want by changing the ‘paused’ variable to one. Every script will have to wait until the ‘paused’ variable is zero again before they can continue running!
wait until <(paused?) = [0]>
That way, you can pause the project whenever you want by changing the ‘paused’ variable to one. Every script will have to wait until the ‘paused’ variable is zero again before they can continue running!
- scratchcode1_2_3
-
Scratcher
1000+ posts
How to make pause button
It should look a bit like this, in all the sprites:
And In the pause button sprite it should look like this:
when green flag clicked
forever
if <(paused) = [false]> then
...
end
end
And In the pause button sprite it should look like this:
when green flag clicked
set [paused v] to [false]
forever
wait until <anything happens:: #00FFFF> //can be space bar or click
wait until <not<anything happens::#00FFFF>>
set [paused? v] to [true]
wait until <anything happens:: #00FFFF> //can be space bar or click
wait until <not<anything happens::#00FFFF>>
set [paused? v] to [false]
Tell me if that works!
end
- nerdloop330
-
Scratcher
100+ posts
How to make pause button
Mostly correct, but it has to be a ‘wait until’ block. If it's an ‘if / then’ block any code inside it will keep on running until it loops and discovers the ‘pause’ variable is now true and therefore cannot continue.
Last edited by nerdloop330 (Aug. 16, 2022 06:29:48)
- blackspider222
-
Scratcher
50 posts
How to make pause button
Here is the script, Please contact me on my Profile If you see any bugs or it doesnt work.
And the this is the pause sprite code
when green flag clicked
set [pause v] to [not paused]
forever
if <[pause] = [not paused]> then
Your controls If its a game or something
broadcast [A random message (to "contact the other sprites" That its not "paused anymore" v]
else
end
end
And the this is the pause sprite code
when green flag clicked
go to x: (your choice (ill recommend 0 if its not going to block anything or if it is, i suggest top right corner) y: (your choice (ill recommend 0 if its not going to block anything or if it is, i suggest top right corner)
switch costume to [the costume for the not paused v]
when this sprite clicked
next costume
set [pause v] to [paused]
Last edited by blackspider222 (Aug. 16, 2022 10:56:07)
- Tornisterz
-
Scratcher
13 posts
How to make pause button
Wow thank you everyone.
hmm, i think mine wont be easy to pause, i think you'll know why, check my project called “baby care” the coding is all over the place! variables just flying around … but i think i'll try!
hmm, i think mine wont be easy to pause, i think you'll know why, check my project called “baby care” the coding is all over the place! variables just flying around … but i think i'll try!
Last edited by Tornisterz (Aug. 29, 2022 00:54:39)
- Tornisterz
-
Scratcher
13 posts
How to make pause button
That depends on what your project is about. An easy way to make a pause function is to use this code frequently:wait until <(paused?) = [0]>
That way, you can pause the project whenever you want by changing the ‘paused’ variable to one. Every script will have to wait until the ‘paused’ variable is zero again before they can continue running!
what should i put in the sprites so it can react to pause when its 0?, and i was wondering if variable value still works if i hide them, sorry im kinda new
idk how i made a studio
- nerdloop330
-
Scratcher
100+ posts
How to make pause button
Yes! Variables can work even if you hide them. The point of hiding variables is so that the screen doesn't get clogged up with them. Also, you would need a
set [paused? v] to []block to allow the previous script to work. If you set the variable to one, the script will wait until it's set back to zero before it continues running. Simple!
- Tornisterz
-
Scratcher
13 posts
How to make pause button
Yes! Variables can work even if you hide them. The point of hiding variables is so that the screen doesn't get clogged up with them. Also, you would need aset [paused? v] to []block to allow the previous script to work. If you set the variable to one, the script will wait until it's set back to zero before it continues running. Simple!
Sounds simple, but cluttered when i try on my project, its because i have lots of sprite with crazy commands , check it out by clicking my profile and click baby care, look inside or just have fun playing it, im still updating, i want to add cancel vol and also pause
and i dont know how to pause variables too
tysmmmmm for your help
Last edited by Tornisterz (Aug. 30, 2022 03:27:51)
- KaaBEL_sk
-
Scratcher
100+ posts
How to make pause button
At first you should cleanup all green flag scripts for initialization and forever loops into one script. That should help a lot and make it more easier to add pause feature.
For example having scripts:
For example having scripts:
when green flag clickedIt's good to have one script for those:
go to x: (0) y: (0)
when green flag clicked
switch costume to [player v]
show
when green flag clicked
wait (5) secs
show variable [variable v]
show variable [health v]
show variable [score v]
when green flag clicked
wait (5) secs
forever
if <(health) < (50)> then
say [you are ill] for (2) secs
end
end
when green flag clicked
wait (5) secs
forever
if <(score) > (1000)> then
broadcast (winscreen v)
end
end
when green flag clicked
go to x: (0) y: (0)
switch costume to [player v]
show
wait (5) secs
show variable [variable v]
show variable [health v]
show variable [score v]
forever
if <(health) < (50)> then
say [you are ill] for (2) secs
end
if <(score) > (1000)> then
broadcast [winscreen v]
end
end
- tiaza
-
Scratcher
500+ posts
How to make pause button
Help me guys! how do I make a pause button? need help for my new project, also im new here, check out me games, most of them are 1 day buildsHi! Here a solution:
First step: Make a new sprite.
2. Step:
when this sprite clicked
stop [ v]
- CoconutGator
-
Scratcher
1000+ posts
How to make pause button
But then how would the project start again? This seems more like a quit button than a pause button.Help me guys! how do I make a pause button? need help for my new project, also im new here, check out me games, most of them are 1 day buildsHi! Here a solution:
First step: Make a new sprite.
2. Step:when this sprite clicked
stop [ v]
- tiaza
-
Scratcher
500+ posts
How to make pause button
Oh yeah sorry my faultBut then how would the project start again? This seems more like a quit button than a pause button.Help me guys! how do I make a pause button? need help for my new project, also im new here, check out me games, most of them are 1 day buildsHi! Here a solution:
First step: Make a new sprite.
2. Step:when this sprite clicked
stop [ v]
- mcgoomba
-
Scratcher
1000+ posts
How to make pause button
If you don't need a pause screen do this:
If you want a pause screen make a new sprite for the pause screen and do this somewhere:
forever
if <key (your pause button v) pressed?> then
wait until <key (your pause button v) pressed?>
end
... // game logic here
end
If you want a pause screen make a new sprite for the pause screen and do this somewhere:
forever
if <key (your pause button v) pressed> then
show
wait until <key (your pause button v) pressed?>
hide
end
end
... // you can put other things in this new sprite too!
- coolmaker229
-
Scratcher
3 posts
How to make pause button
there's no “Your Pause Button” key on PC tho.
- XXNutellaYummyXX
-
Scratcher
2 posts
How to make pause button
This is the project I need help with, the pause button https://scratch.mit.edu/projects/1294247000/
Last edited by XXNutellaYummyXX (March 23, 2026 22:04:09)
- mushroom_314
-
Scratcher
15 posts
How to make pause button
when green flag clicked
set [pause v] to (0)
forever
if <(pause) = (0)> then
…
end
end
- Discussion Forums
- » Help with Scripts
-
» How to make pause button