Stop ()
2.0 Stop ().png
Category Control
Type Cap/Stack (changes depending on argument)
Introduced in 2.0

The Stop () block is a Control block. Depending on the argument, it is either a Cap block ("all" or "this script"), or a Stack block ("other scripts in sprite"). It is the only block that changes its shape. It was added in Scratch 2.0 to replace the Stop All and Stop Script blocks, and also to add the functionality of stopping other scripts in a sprite. If there are blocks below it and it is a stack block, the other options will be missing.

Example Uses

Stopping other scripts in the sprite, as a stack block.

This block can be used in some of the following ways:

  • Ending a project once all the actions are carried out
when I receive [end v]
say [That's all folks!] for (2) secs
stop [all v]
  • Stopping a project — when all lives are lost, for example
when gf clicked
forever
if < (lives) = [0] > then
stop [all v]
end
  • Disabling controls
when gf clicked
forever
if << key [up arrow v] pressed? > and < (jumping) = [0] > > then
set [delta-y v] to [5]
end
if < (level) = [7] > then
stop [this script v]
end
  • Disabling a sprite
when gf clicked
forever
if < (x position) > [100] > then
stop [other scripts in sprite v]
stop [this script v]
end
  • Only performing an action a certain amount of times, and then stopping
when gf clicked
set [x v] to [0]
forever
if < (x) = [5] > then
stop [this script v]
end
move (10) steps
if on edge, bounce
change [x v] by (1)
  • Implementing recursion-based procedures (as an end condition)
define factorial (n)
set [result v] to (n)
set [counter v] to ((n) - [1])
forever
if < (counter) > [1] > then
set [result v] to ((result) * (counter))
change [counter v] by [-1]
else
stop [this script v]
end
end

when gf clicked
factorial (5)
say (result) for [2] seconds // notice how the main script doesn't stop