Learning Goals 3 min
By the end of this lesson you will be able to:
- Use delete this clone to remove a clone from the project the moment it's no longer needed.
- Explain Scratch's 300-clone cap and predict what happens to a spawner when the cap is hit (it silently stops working).
- Combine delete this clone with a condition — touching [edge v]?, off-screen y-position, or touching [Player v]? — so each clone deletes itself at exactly the right moment.
Warm-Up — the pile that never stops 7 min
Last lesson you built falling raindrops. They spawn at the top and drift to the bottom. Here's the stack you wrote:
when flag clicked
hide
forever
create clone of (myself v)
wait (0.2) seconds
end
when I start as a clone
go to x: (pick random (-200) to (200)) y: (180)
show
forever
change y by (-3)
end
Click the flag. Watch carefully. After about a minute, what happens?
Reveal the answer
Around the 60-second mark, the rain stops. New clones stop appearing at the top. The clones already on-screen keep falling and eventually drift below the Stage — but the spawner has gone silent. Why? Because Scratch has a hard cap of 300 live clones. The clones that fell off the bottom are still alive (just off-screen); they never got deleted. Once you've stacked up 300 of them, every new create clone of (myself v) is silently ignored. The spawner is still running — it just can't make clones anymore.
Today's block fixes that. delete this clone ends a clone's life so it stops counting toward the 300. Use it wisely and your spawner can keep firing forever.
New Concept — delete this clone 15 min
Two lessons ago you met create clone of (myself v). Last lesson you met when I start as a clone. Today is the third and final clone block — the one that closes the loop.
Where to find it
Open the Control palette. Scroll to the bottom, right below the other clone blocks. You'll see a stop-cap-shaped block (flat top, jagged bottom — same shape as stop [all v]):
delete this clone
"This clone" means the clone running this stack
The word this is important. When a clone runs delete this clone, it deletes itself — not any other clone, not the original. Every clone has its own copy of the script running, and "this" always means "the copy currently being executed".
The original sprite is safe. If you put delete this clone on the original (under when ⚑ clicked), nothing happens — the original isn't a clone, so the block has no target.
The 300-clone cap
Scratch caps the number of live clones at 300 across the whole project (not per sprite). Hit the cap and create clone of (myself v) silently does nothing. No error, no warning. Your spawner just stops working and you wonder why.
The solution is to delete clones as soon as they're done with their job. Common moments to delete:
- Clone touched the edge → game world boundary reached.
- Clone went off-screen (y < −170 or x > 240).
- Clone touched the player → enemy caught.
- Clone touched a bullet → enemy shot.
- Clone finished an animation → effect complete.
Pattern 1: forever + if + delete
The most common pattern. Inside the clone hat, run a forever loop. Each frame, ask a question. If the question is true, delete.
when I start as a clone
go to x: (pick random (-200) to (200)) y: (180)
show
forever
change y by (-3)
if <touching [edge v] ?> then
delete this clone
end
end
Pattern 2: repeat until + delete
If the condition is "keep going until X", use repeat until <>. The clone repeats the action, checks the condition, and when the condition becomes true, it falls out of the loop — and the very next block deletes it.
when I start as a clone
go to x: (pick random (-200) to (200)) y: (180)
show
repeat until <(y position) < (-170)>
change y by (-3)
end
delete this clone
Both patterns work. Pattern 1 (forever + if) feels more natural for game loops where many things might trigger deletion. Pattern 2 (repeat until) is cleaner when there's exactly one exit condition.
Worked Example — endless rain that doesn't pile up 12 min
We're going to take last lesson's rain project, turn the spawner into a never-ending forever, and add delete this clone so the rain runs forever without ever hitting the 300 cap.
Step 1 — Open last lesson's project
Open the Raindrop project from L03-22. (Or build a fresh one — small blue oval sprite, costume centred.)
Step 2 — Change the spawner to a forever
On the original sprite, find repeat (10). Drag it out and replace it with forever. Keep the create clone of (myself v) and wait (0.5) seconds inside.
Step 3 — Test before the fix
Click the flag. Let it run for one minute. Confirm the rain stops — that's the cap kicking in. Click the red stop button.
Step 4 — Add the delete condition
In the clone-hat stack, find the forever loop. Inside it, below change y by (-3), drop in if <> then.
Step 5 — Add the boolean question
From Sensing: touching [edge v] ?. Drop it into the diamond slot of the if-then.
Step 6 — Add the delete
From Control: delete this clone. Drop it inside the if-then C.
Step 7 — Test the fix
Click the flag. Let it run for two minutes. The rain keeps falling. Old clones are deleting themselves at the bottom edge as fast as new ones spawn at the top.
Step 8 — Watch one clone die
Temporarily replace delete this clone with say [goodbye] for (0.5) seconds. Click the flag. You'll see "goodbye" pop up at the bottom edge every time a clone gets there. That confirms your if-then is firing at exactly the right moment. Put delete this clone back when you're done.
The full assembled stacks
when flag clicked
hide
forever
create clone of (myself v)
wait (0.5) seconds
end
when I start as a clone
go to x: (pick random (-200) to (200)) y: (180)
show
forever
change y by (-3)
if <touching [edge v] ?> then
delete this clone
end
end
What you just built: the spawn-act-die cycle that every Scratch shooter, snowfall, bullet, and enemy uses. Spawner on the original. Behaviour and death condition on the clone hat. Forever-balanced.
Try It Yourself — three delete drills 15 min
Goal: A self-deleting "hello" balloon. Spawn one clone at the mouse pointer when you click the green flag. The clone should say [Hello!] for (2) seconds and then delete itself.
when flag clicked
hide
create clone of (myself v)
when I start as a clone
go to (mouse-pointer v)
show
say [Hello!] for (2) seconds
delete this clone
Think: No loop needed. The clone runs four blocks top-to-bottom, then deletes. Notice delete this clone sits at the bottom — nothing can snap below it, which is the visual hint that the clone is gone.
Goal: Endless bouncing balls. Spawn a ball every 0.3 seconds. Each ball appears at a random x at y: 150, drops with change y by (-5), and deletes itself when it touches the bottom edge. The project should be able to run for 5 minutes without slowing down.
when flag clicked
hide
forever
create clone of (myself v)
wait (0.3) seconds
end
when I start as a clone
go to x: (pick random (-220) to (220)) y: (150)
show
repeat until <(y position) < (-170)>
change y by (-5)
end
delete this clone
Think: This uses Pattern 2 — repeat until + delete this clone below it. Cleaner than Pattern 1 here because there's exactly one exit condition. Pick the pattern that reads most naturally.
Goal: Build a simple catch-the-bananas game. A Player sprite follows the mouse along the bottom of the Stage. Banana clones spawn at the top, fall, and delete themselves when they either (a) touch the bottom edge (missed) or (b) touch the Player sprite (caught). Two deletion conditions in one if-then-or pattern.
when flag clicked
hide
forever
create clone of (myself v)
wait (0.6) seconds
end
when I start as a clone
go to x: (pick random (-200) to (200)) y: (170)
show
forever
change y by (-4)
if <<touching [edge v] ?> or <touching [Player v] ?>> then
delete this clone
end
end
Think: The <> or <> operator from Operators lets one if-then watch for either condition. You don't care why the banana left the scene — caught or missed, just delete it. Score-counting (catch = +1) is a lesson for next week.
Mini-Challenge — Faiz's stuck spawner 5 min
"My spawner just dies after a while"
Faiz is making a starfield. He wants stars to keep appearing forever. He writes this:
when flag clicked
hide
forever
create clone of (myself v)
wait (0.1) seconds
end
when I start as a clone
go to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))
show
forever
change [ghost v] effect by (1)
end
The stars fade to invisible (ghost effect goes from 0 to 100 to fully transparent and beyond) but they never actually leave the project. Why does Faiz's spawner stop?
Reveal one valid solution
Each clone runs a forever loop that just keeps changing the ghost effect. Once ghost is 100, the clone is invisible — but it's still alive. The forever loop never ends, the clone is never deleted, and after ~30 seconds Faiz has stacked up 300 invisible clones. The spawner silently hits the cap and stops.
The fix is to end the loop when the clone is fully faded, then delete:
when flag clicked
hide
forever
create clone of (myself v)
wait (0.1) seconds
end
when I start as a clone
go to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))
set [ghost v] effect to (0)
show
repeat (100)
change [ghost v] effect by (1)
end
delete this clone
Now each clone fades over exactly 100 frames (about 3 seconds at 30 FPS), then deletes itself. The spawner can run forever — clones come and go in balance. Invisible is not the same as deleted. If a clone has no future job to do, kill it.
Recap 3 min
You met the third and final clone block. delete this clone ends the life of the clone that runs it — and only that clone. Use it to balance every create clone of (myself v) so your project doesn't slowly fill up and silently hit Scratch's 300-clone cap. The two most common patterns are forever + if + delete (for game loops with many possible exit reasons) and repeat until + delete (for one clear stop condition). Always pair "what does the clone do?" with "when does the clone die?" — they're two halves of the same thought. Next lesson you'll learn how to count clones with a variable so you can know exactly how many are alive at any moment.
- delete this clone
- A Control block that removes the clone currently running this stack. Has a jagged bottom — nothing can snap below it because the clone won't exist anymore.
- 300-clone cap
- Scratch's hard limit on how many clones can be alive in a project at one time. Hit it and create clone of (myself v) silently does nothing.
- Clone leak
- When clones are created but never deleted, so the live count grows over time. Symptom: project slows down, then the spawner mysteriously stops.
- Exit condition
- The boolean question that decides when a clone should die. Common ones: touching [edge v]?, (y position) < (-170), touching [Player v]?.
- Spawn-act-die
- The three-part life cycle of every clone in a well-built project: spawn (create), act (run behaviour), die (delete this clone). Skip the third step and you have a leak.
Homework 2 min
The Five-Minute Test. Take your HW-L3-22-Pisang-Goreng-Rain.sb3 from last week and add deletion so it can run for five minutes without slowing down or stopping.
- Open the project. Change the repeat (15) in the spawner to a forever, so it keeps spawning.
- In the clone hat, inside the forever loop that falls, add if <touching [edge v] ?> then + delete this clone.
- Click the flag. Set a timer for five minutes. The rain should never stop.
- Bonus: also delete the clone if (y position) < (-170) — sometimes touching [edge v]? misses fast-moving clones by one frame.
Save as HW-L3-23-Endless-Pisang.sb3.
Bring back next class:
- The
.sb3file. - Your answer to: "How many clones do you think are alive on the Stage at any moment in your project? Could you actually count them with the blocks you know today? (Hint: you can't — yet.)"
Heads up for next class: SCR-L03-24 answers exactly that question. There's no built-in "how many clones?" block, so we'll use a variable trick to track the count ourselves.