Learning Goals 3 min
By the end of this lesson you will be able to:
- Drag a forever c-block onto the Script Area and snap body blocks inside it.
- Combine move (10) steps with if on edge, bounce inside a forever loop to make the cat ping-pong across the Stage.
- Press the red stop sign above the Stage to halt a running forever loop.
Warm-Up 7 min
Last lesson you built a repeated dance move — the cat bowed and shimmied a set number of times. Today's loop has no number, so the dance never stops on its own.
Quick-fire puzzle
Mei Ling built this loop. She clicked the green flag — then walked away from her laptop for ten minutes. What did she find when she came back?
when flag clicked
repeat (5)
move (10) steps
end
Reveal the answer
The cat had moved 50 steps and then stopped — exactly where it landed five seconds after the click. The loop ran its five rounds and finished. Once a repeat (10) loop finishes, that's it. To restart it, Mei Ling has to click the flag again.
What if she wanted the cat to keep going? Dance forever, until she presses stop? That's today's block.
New Concept — the forever c-block 15 min
Think of forever as a heart beating. It runs the blocks inside its mouth, then runs them again, then runs them again — never stopping on its own. The only way out is the red stop sign above the Stage. (We'll learn more grown-up ways to stop a forever in the next lesson.)
Blocks reference
| Block | Category | What it does |
|---|---|---|
| forever | Control | Runs the blocks inside its mouth over and over with no end. Stops only when the red stop sign is pressed. |
| if on edge, bounce | Motion | If the sprite is touching an edge of the Stage, it flips direction. If it's not, nothing happens. |
The shape of forever
Forever looks almost like repeat (10) — same C-shape, same mouth — but with two differences:
- There is no number input. Forever doesn't count.
- There is no notch at the bottom. You can't snap anything after a forever, because nothing after a forever would ever run.
when flag clicked
forever
move (5) steps
end
Repeat vs forever — when to use which
Same C-shape. Very different jobs.
| Loop | How long it runs | Good for |
|---|---|---|
| repeat (10) | Exactly N times, then stops. | Tracing a shape, taking N steps, saying something N times. |
| forever | Until the red stop sign is pressed. | Animation that should never stop, "always listen" behaviours, background motion. |
The red stop sign
The red octagon next to the green flag is the stop button. Click it and every script in the project halts immediately — including any forever loop in mid-run. The cat freezes wherever it landed. Click the green flag again to restart.
Why it matters
Forever is the heartbeat of almost every Scratch game and animation. The fish swims forever, until the player stops the game. The score watches the apples forever, until the round ends. Forever turns a one-off action into ongoing behaviour.
Worked Example — the bouncing cat 15 min
Open Scratch. Make sure the cat is somewhere near the centre (x = 0, y = 0) and facing right (Direction = 90). We'll make it slide side to side across the Stage, bouncing off each edge, forever — until you press stop.
Step 1 — Drag the hat block
Drag when ⚑ clicked from Events into the Script Area.
Step 2 — Find the forever block
Click the orange Control category. Just below repeat (10) sits forever. Drag it under the hat block.
Step 3 — Drop a move block into the mouth
Grab move (10) steps from Motion. Drop it inside the forever's mouth.
Step 4 — Add the edge-bounce block
Still in Motion, find if on edge, bounce at the bottom of the category. Drag it under the move block, still inside the mouth.
when flag clicked
forever
move (10) steps
if on edge, bounce
end
Step 5 — Click the green flag
The cat starts sliding right. Faster than it looked when you clicked it one move at a time — because the loop runs as fast as the computer can. When the cat hits the right edge of the Stage, if on edge, bounce flips its direction. Now it slides left. Hits the left edge. Flips. Slides right. Hits the right edge. Flips. Forever.
Step 6 — Press the red stop sign
Find the red octagon next to the green flag. Click it. The cat freezes. The forever loop has been told to stop.
Step 7 — Click the green flag again
The cat resumes sliding. Forever doesn't remember its history — it just starts a fresh forever every time the flag is clicked.
What changed: last lesson's repeat (10) ran a body N times and stopped. This forever has no number — it relies on you (the red stop sign) to end it.
The full assembled stack (your reference)
when flag clicked
forever
move (10) steps
if on edge, bounce
end
Try It Yourself — three small builds 12 min
Goal: Slow the bouncing cat down. Add a tiny wait inside the loop so each step is visible.
when flag clicked
forever
move (10) steps
if on edge, bounce
wait (0.05) seconds
end
Think: A 0.05-second wait is a twentieth of a second — fast, but enough to give the move a smoother feel. Try 0.1. Try 0.5. Notice how the cat's motion changes character.
Goal: Make a spinning cat. Replace the bounce with a turn — the cat spins on the spot forever.
when flag clicked
forever
turn cw (5) degrees
wait (0.05) seconds
end
Think: No move in the body — just turn. The cat stays in place but rotates. This same pattern is how a windmill, a fan, or a spinning coin gets animated.
Goal: Make Aisyah's cat bounce and talk. Each time the cat starts a new loop pass it whispers "Cuba lagi!" ("Try again!") for half a second.
when flag clicked
forever
say [Cuba lagi!] for (0.5) seconds
move (20) steps
if on edge, bounce
end
Think: The forever runs three blocks in order, then repeats. The 0.5-second say slows the loop down naturally — you don't need a wait block. The speech bubble flickers on and off as the loop cycles.
Mini-Challenge — two scripts, one forever 5 min
"The bouncing cat that counts its laps in your head"
Combine today's forever with the when [space v] key pressed hat from earlier. Build two separate scripts: one starts the cat bouncing forever; the other makes the cat say "Bounce!" every time you press the space bar.
It works if:
- You click the green flag once. The cat starts bouncing across the Stage.
- Every press of the space bar makes the cat say "Bounce!" for one second — while still bouncing.
- The red stop sign halts everything.
Reveal one valid solution
Two hat blocks → two scripts. They run at the same time. The cat is doing two things at once — bouncing forever, and listening for the space bar.
when flag clicked
forever
move (10) steps
if on edge, bounce
end
when [space v] key pressed
say [Bounce!] for (1) seconds
Two stacks, separated by a blank line — the renderer treats each hat as the start of a new script. Both run in parallel. Scratch is happy to run lots of scripts at the same time on the same sprite.
Recap 2 min
Today you met forever — the c-block that never stops on its own. It looks like repeat (10) but has no number and no bottom notch. The only way to halt a forever is the red stop sign above the Stage. You used it with if on edge, bounce to make the cat slide back and forth across the Stage with no end.
- forever (block)
- A Control c-block that runs its body over and over with no end. Stops only when the red stop sign is pressed.
- Red stop sign
- The red octagon next to the green flag above the Stage. Click it to halt every running script in the project.
- if on edge, bounce (block)
- A Motion block. If the sprite is touching a Stage edge, it flips direction. Otherwise it does nothing.
- Parallel scripts
- Two or more scripts on the same sprite that run at the same time. Each has its own hat block.
Homework 1 min
The Pendulum Cat. Build a forever loop that makes Wei Jie's cat swing back and forth like a pendulum — turn a small amount one way, then a small amount back, forever.
- Open Scratch. Centre the cat (x =
0, y =0). Direction =90. - Build this stack:
when flag clicked
forever
turn cw (10) degrees
wait (0.1) seconds
turn ccw (10) degrees
wait (0.1) seconds
end
Bring back next class:
- A screenshot of your Script Area showing the six-block stack.
- Your written answer to this question: "After ten seconds, where is the cat facing — the same direction it started, or a different one? Why?" (Hint: every turn cw (10) is undone by a turn ccw (10) right after it.)
Heads up for next class: SCR-L01-21 teaches a politer way to stop a script — the stop [this script v] block, plus its big brother stop [all v]. You'll learn when to use each.