Forever (block)

2.0 Forever.png
Category Control
Type C

The Forever block is a Control block and a C block. Blocks held inside this block will be in a loop — just like the Repeat () block and the Repeat Until () block, except that the loop never ends (unless the stop sign is clicked, the Stop All block is activated, or the stop script block is activated within the loop). Due to this infinite loop, the block has no bump at the bottom; having a bump would be pointless, as the blocks below it would never be activated.

This block has a slight delay, so for optimum speed of execution, single frame block stacks should be used.

An example of the behavior of a forever loop

How to Write it in the Forums or Wiki

  • forever


Example Uses

The block is one of the most commonly used blocks in Scratch because there are a lot of cases when an infinite loop is needed. Some common uses are:

  • Keeping a sprite at another's location
go to [Sprite1 v]
  • A music loop
play sound [Battle theme v] until done
repeat (12)
turn left (3) degrees
repeat (12)
turn right (3) degrees


Main article: List of Block Workarounds

This block can be replicated in three ways: With a boolean statement that will never be true, through recursion, or through reporters that return "Infinity".

With the boolean method, the Repeat Until () block is used, along with the boolean statement. There are many that will never be true, including:

<[1] = [-1]>
<[a] = [b]>
<(timer) = [-1]>
<not <not <>>>
<<> or <>>

A full workaround:

repeat until <[1] = [-1]>
. . .

One method that does not involve false boolean statements is tail recursion. Tail recursion can be created by a script broadcasting the broadcast needed to start it, thus repeatedly running the script:

when I receive [Recursion v]
. . .
broadcast [Recursion v]

This has some benefits to making projects. For example, the script is helpful since it can be used to create fractals.

This also works:

repeat ([10^ v] of (309) :: operators)
. . .

This requires an operator that reports "Infinity", like:

([10^ v] of (309) :: operators)
([e^ v] of (1000) :: operators)
(join [Infinity] [])
((1) / (0))

All of these will work in the last workaround.

You can also use:

define foreverloop
. . .
foreverloop :: custom

See Also

  • This page was last modified on 19 March 2017, at 17:38.