- Learnt28 min · clone, clone script, delete, count
- Basic24 min · a stream of bubbles
- Challenge 1–327 min · forget the delete, count them, a burst
- Extrabonus · the 300 ceiling
Review — the Firework Show arc 5 min
- A My Block holds a stack under a name, and inputs let the call vary it.
- Run without screen refresh finishes a definition before the Stage redraws.
- Refactoring rearranges code without changing what it does.
Quick-fire
Your firework block made sixty sparks, and every one of them was the same colour even though you wanted different ones. Why could you not fix that?
Reveal the answer
Because the sparks read a shared variable, so the last one set the colour for all of them. This arc is about giving every clone its own — and this lesson is the groundwork for it.
Today’s Topic 3 min
create clone of [myself v]— a copy that runs by itselfwhen I start as a clone— the hat only clones rundelete this clone— and why forgetting it breaks the game- Counting how many are alive, and the ceiling Scratch puts on it
Learning outcome
By the end of this lesson you will be able to:
- Make many copies of one sprite and give them all a job.
- Have each copy tidy itself away when it is finished.
- Keep a count of how many are alive right now.
Learnt — one sprite, many bubbles 28 min
1 · The problem with one sprite
A sprite is in one place at a time. Send a bubble up from the seabed and you have one bubble; send another and the first has to come back down first.
How to use this: Click the green flag and watch three bubbles go up, one after another. Never two at once.
2 · A clone is a copy that runs itself
You met clones in Level 2 and used them for firework sparks. Here is what is actually happening:
create clone of [myself v]makes a copy of the sprite, exactly where it is, with everything it has.- The copy immediately runs any
when I start as a clonescript — its own run of it, separate from every other clone. - The original carries on with what it was doing.
when flag clicked
hide
repeat (12)
go to x: (pick random (-180) to (180)) y: (-170)
create clone of [myself v]
wait (0.35) seconds
end
when I start as a clone
show
repeat until <(y position) > (165)>
change y by (5)
end
delete this clone
How to use this: Click the green flag. Twelve bubbles rise at once, and the counter shows how many are alive.
3 · Every clone must tidy itself away
delete this clone removes the clone that runs it — not all of them, just that one. It belongs at the end of the clone script, when the bubble has finished:
when I start as a clone
change [bubbles v] by (1)
show
repeat until <(y position) > (165)>
change y by (5)
end
change [bubbles v] by (-1)
delete this clone
4 · What clones share, and what they do not
A clone starts with a copy of everything the sprite had: its costume, its size, its position, its effects. From that moment it goes its own way — moving one clone does not move the others.
But variables are still shared, and that is the big surprise waiting in the next lesson. For today, every bubble does the same thing at the same speed, and that is fine.
Basic — a stream of bubbles 24 min
Start a new project. A reef backdrop and one round sprite.
Step 1 — the sprite
- Add the
Ballsprite. It has five colours as costumes. - Set its size to about 40.
Step 2 — the spawner
- Under the green flag:
hide, thengo to x: (0) y: (-175). - Add
repeat (26). - Inside: go to a random x at the seabed, then
create clone of [myself v], then a short wait.
Step 3 — the bubble’s life
- Add
when I start as a clone. show, thenrepeat until <(y position) > (165)>holdingchange y by (5).- Finish with
delete this clone.
Step 4 — count them
- Make a variable
bubbles, set it to 0 under the flag, and show it. - Bump it up at the top of the clone script and down just before the delete.
- Run it and watch the number rise and settle rather than climbing for ever.
Step 5 — make them look different
- In the spawner, add
switch costume to (pick random (1) to (5))before the clone block. - In the clone script, add
set size to (pick random (30) to (55)) %.
when flag clicked
hide
set [bubbles v] to (0)
set [made v] to (0)
repeat (26)
go to x: (pick random (-180) to (180)) y: (-170)
switch costume to (pick random (1) to (5))
create clone of [myself v]
change [made v] by (1)
wait (0.28) seconds
end
How to use this: Click the green flag and watch a steady stream. The bubbles box settles; the made box only climbs.
There is one bubble sitting at the bottom that never moves.
That is the original sprite. It needs hide under the green flag — clones copy the hidden state and then show themselves.
Nothing appears at all.
The clone script is missing its show, so every clone is hidden like the original.
The bubbles box climbs and never comes down.
The change [bubbles v] by (-1) is missing, or it is below the delete — where it never runs.
They all appear at the same spot.
The go to x: () y: () is inside the clone script instead of the spawner, so every clone moves to the same new place.
Forget the delete
Break it on purpose, so you recognise it when it happens by accident.
- Take the delete out of your clone script.
- Run it and watch the counter.
- Write down what happens to the project after a while.
How to use this: Click the green flag. Sixty clones are made and not one of them ever leaves.
delete this clone does after a minute of play.Teacher note
This is the single commonest clone bug and it never announces itself — the game just degrades. Getting pupils to cause it deliberately once is worth more than a warning.
How busy did it get?
Track the most bubbles that were ever on screen at the same time.
- A
bubblescounter that goes up on birth and down on death. - A
most at oncethat only ever goes up. - Change the spawn wait and watch the peak change.
How to use this: Click the green flag and watch both boxes. One settles, the other keeps its record.
Teacher reveal — the “biggest so far” shape again
change [bubbles v] by (1)
if <(bubbles) > (most at once)> then
set [most at once v] to (bubbles)
end
The same three blocks as the strongest card in Lesson 3-9 and the worst till day in 3-4. Point that out — a pupil who recognises a shape they have used before is learning the thing that actually transfers.
A burst of ten
Instead of a trickle, send up ten at once, three times over.
- Ten clones made with no wait between them.
- A pause between the bursts, not inside them.
- They spread across the seabed rather than stacking up.
How to use this: Click the green flag and watch three waves of ten come up together.
Teacher note
A loop inside a loop, and the only difference from the stream is where the wait sits. Worth asking them to predict what happens if the wait stays inside — most will say “nothing much” and be surprised.
Find the ceiling
Scratch will not make unlimited clones. Find out where it stops — and notice how it tells you.
- Ask for 350 clones as fast as you can.
- Count how many you asked for and how many you got.
- Say what error message Scratch gave you.
How to use this: Click the green flag and watch the two numbers. One reaches 350; the other stops.
Teacher note
The follow-up matters more than the limit: with deletes in place a game can make thousands of clones over a session, because only the ones alive at oncecount towards 300. That is the practical rule pupils should leave with.
Summary 5 min
create clone of [myself v]copies the sprite; the copy runs its ownwhen I start as a clone.- Hide the original. It is the spawner, not a bubble.
delete this cloneremoves just that one, and every clone needs it.- Count up on birth and down on death, and the number means “alive now”.
- Scratch stops at 300 clones and says nothing. Only the living ones count.
- Clone
- A copy of a sprite that runs its own scripts.
- Spawner
- The hidden original whose job is to make clones.
- Clone script
- Everything under
when I start as a clone. - Population
- How many clones are alive at this moment.
Hand in
Save your reef. Next lesson every bubble gets its own speed and its own size — and you find out why that was impossible until now.