Learning Goals 3 min
By the end of this lesson you will be able to:
- Drag when I receive (message v) from the Events palette and explain that it is a hat block — it starts a new script when a matching broadcast arrives.
- Put several when I receive hats on a single sprite, each listening for a different message, each running a different script. One sprite can have many ears.
- Place a receiver hat on a sprite (or the Stage) that didn't send the broadcast — proving that broadcasts work across sprites and that the listener does not need to know who the sender is.
Warm-Up — predict who reacts 7 min
Last lesson you met broadcast (start race v) — the sender. This lesson is all about the other half: the listener.
Puzzle 1 — two ears on one cat
The cat has these two stacks both on the same sprite:
when I receive (start v)
move (50) steps
when I receive (stop v)
say [Done!] for (1) seconds
A drummer sprite (separate from the cat) broadcasts start, waits 1 second, then broadcasts stop. What does the cat do?
Reveal the answer
The cat jumps forward 50 steps (the start script fires), then about 1 second later says "Done!" for 1 second (the stop script fires). Two separate scripts ran, one after the other, on the same sprite — because the cat has two different ears. That's totally fine in Scratch and very common.
Puzzle 2 — the wrong listener
A button sprite has when this sprite clicked → broadcast (hop v). The cat has nothing — no scripts at all. The fish has when I receive (hop v) → change y by (50). Click the button. Who hops?
Reveal the answer
The fish hops. The cat does nothing. Broadcasts don't go to the "obvious" sprite — they go to whichever sprite is listening. The button sent a cue to nobody in particular; the fish happened to be the only one listening for it, so the fish reacted.
Today's lesson is the listener's side of the broadcast story. We'll pile multiple when I receive hats onto one sprite, listen for cues from sprites we never even talk to, and even put receivers on the Stage.
New Concept — receivers, ears, and cross-sprite scripts 15 min
L02-20 was all about the sender: the marshall blowing the whistle. This lesson zooms in on the runners — the scripts that wake up when the whistle blows. The block at the heart of it all is the yellow hat from the Events palette:
when I receive (start v)
move (50) steps
It's a hat block, just like (when ⚑ clicked)
Hat blocks start scripts. They aren't called from anywhere — they wait for something to happen, and then they fire. You already know when ⚑ clicked, when this sprite clicked, and when [space v] key pressed. when I receive is the same idea: it fires when a matching broadcast lands.
That means every rule you know about hat blocks applies:
- Nothing snaps above a hat. It's the top of its stack.
- A sprite can have as many hats as it wants, of any kinds, in any combination.
- Two hats can fire at the same instant — they each spawn an independent script that runs in parallel.
One sprite, many ears
Here's the bit that surprises a lot of beginners. A single sprite can have multiple when I receive hats — one per message it cares about. Each one runs a different script:
when I receive (start v)
go to x: (-200) y: (0)
show
when I receive (game over v)
say [I lost!] for (2) seconds
hide
when I receive (next scene v)
switch costume to (waving v)
glide (1) seconds to x: (0) y: (0)
Think of the sprite as a phone with three ringtones. Each ringtone plays for a different caller. The phone doesn't have to choose between them — it just listens for all of them and reacts to whichever rings.
Listeners don't need to know senders
This is the deep idea. The receiver hat on the cat doesn't say "when the button sends 'start' to me". It just says "when somebody, somewhere, sends 'start'". The cat has no clue (and doesn't need to know) which sprite sent the broadcast.
That means:
- You can move the sender to a different sprite without touching the receiver.
- You can have several different sprites send the same broadcast (a button or a key press), and the receiver reacts to both without changes.
- You can build the receiver first and the sender later — or vice versa — and they just work the moment both exist with matching names.
The Stage can listen too
Click the white Stage thumbnail (bottom-right of the editor, beside the sprite list). It has its own scripts area. Drop a receiver hat there:
when I receive (night v)
switch backdrop to (Night City v)
night cue and switches the backdrop. Backdrops are to the Stage what costumes are to a sprite.The Stage is a sprite-like thing for script purposes. It can receive broadcasts, and it can send them too. Useful for global things like backdrop changes, music, and timers.
What if two ears fire at once?
If two different broadcasts arrive at the exact same instant on the same sprite, both scripts run in parallel — independently, neither waiting for the other. Same as if two when ⚑ clicked hats fired at the flag. Parallel scripts are a Scratch superpower, but they can collide if both scripts move the sprite or change the same costume. We'll see this happen in the challenge.
Worked Example — the bunga raya with three ears 14 min
One flower sprite. Three receiver hats — one for each scene of a tiny story. Plus a narrator sprite that broadcasts the cues.
Step 1 — New project, two sprites
New project. Delete the cat. Add a Flower sprite from the library (search "flower" — the bunga raya / hibiscus-style one is great). Then add a second sprite — a Storyteller button or any sprite that will broadcast the cues. Call them Bunga and Narrator via the sprite name field at the top of the editor.
Step 2 — Create the three messages on the Narrator
Click Narrator. From Events, drag in broadcast (message1 v). Click its dropdown, pick New message…, type start. Repeat twice more to create game over and next scene. All three names now exist in the project's shared message list.
Step 3 — The Narrator's script
Build a tiny sequencer on the Narrator that broadcasts the three cues with pauses between them, so we can watch the Bunga react to each in turn:
when flag clicked
wait (1) seconds
broadcast (start v)
wait (3) seconds
broadcast (next scene v)
wait (3) seconds
broadcast (game over v)
Step 4 — Click on the Bunga sprite
Switch to the Bunga in the sprite list. Its scripts area is empty.
Step 5 — Drop the first ear
From Events, drag when I receive (message1 v). Open the dropdown and pick start (it's there because the Narrator created it). Add some action below:
when I receive (start v)
go to x: (-150) y: (0)
show
say [Hai!] for (1) seconds
start and gets ready on the left side of the Stage.Step 6 — Drop the second ear (independent stack)
Drag another when I receive hat into the same scripts area. Don't snap it under the first one — leave a gap so it starts a new stack. Pick next scene from the dropdown.
when I receive (next scene v)
glide (2) seconds to x: (150) y: (0)
say [Pindah!] for (1) seconds
Step 7 — Drop the third ear
One more. Drag another when I receive, pick game over, and build a goodbye:
when I receive (game over v)
say [Selamat tinggal!] for (2) seconds
hide
Step 8 — Hide on flag (so the scene starts clean)
Add a fourth, plain hat on Bunga so the flower is invisible until the start cue lands:
when flag clicked
hide
Step 9 — Run the whole show
Click the flag. The Bunga hides immediately. One second later — start: the flower appears on the left and says "Hai!". Three seconds later — next scene: it glides to the right and says "Pindah!". Three more seconds — game over: it waves "Selamat tinggal!" and hides.
The full picture
when flag clicked
hide
when I receive (start v)
go to x: (-150) y: (0)
show
say [Hai!] for (1) seconds
when I receive (next scene v)
glide (2) seconds to x: (150) y: (0)
say [Pindah!] for (1) seconds
when I receive (game over v)
say [Selamat tinggal!] for (2) seconds
hide
What you just built: a sprite that takes direction from outside. The Bunga doesn't decide when to appear, move, or hide — it waits for instructions and reacts. This is exactly how every cutscene, level transition, and menu in every Scratch game works.
Try It Yourself — three listener drills 15 min
Goal: Add a second listener for the same broadcast. Take the worked example and add a third sprite — a kucing (any cat costume from the library). Give the cat its own when I receive (start v) hat that makes it say "Meow!" Both the Bunga and the kucing should react when the Narrator fires start, with no change to the Narrator.
when I receive (start v)
say [Meow!] for (1) seconds
start exactly once; both sprites hear it.Think: Same broadcast, two listeners. The Narrator never knew the cat existed. This is the magic — adding a new reaction never breaks old ones.
Goal: Build a sprite with three ears that all change its costume. Pick the Avery sprite (she has many costumes — happy, sad, surprised). Create three messages on a button sprite: happy, sad, surprised. The button fires whichever you click. On Avery, three receivers each switch to the matching costume.
when I receive (happy v)
switch costume to (avery-a v)
when I receive (sad v)
switch costume to (avery-b v)
when I receive (surprised v)
switch costume to (avery-c v)
Think: Notice how clean this is. No giant if-chain. No variable. Just three hats, one per cue. If you later add a "sleepy" mood, you add one more hat — nothing else changes.
Goal: Put a receiver hat on the Stage. Build two backdrops (Day and Night from the library). On a button sprite, make clicking it broadcast toggle. On the Stage, give it a single receiver hat that switches to the next backdrop every time the cue arrives.
when this sprite clicked
broadcast (toggle v)
when I receive (toggle v)
next backdrop
Think: The Stage is the perfect place for project-wide effects. The button doesn't know how many backdrops exist; it just sends the cue. The Stage handles the rest.
Mini-Challenge — Aljay's fighting ears 5 min
"Why does the cat keep ending up on the wrong side?"
Aljay builds a project where pressing the g key broadcasts go left and pressing the h key broadcasts go right. On the cat:
when I receive (go left v)
glide (3) seconds to x: (-200) y: (0)
when I receive (go right v)
glide (3) seconds to x: (200) y: (0)
Aljay presses g. The cat starts gliding left. Half a second in, he presses h. What happens, and how is it different from what he probably expected?
Reveal one valid solution
Both scripts run in parallel. The "go left" glide is still running when the "go right" glide starts. The cat is now being told to be at x: −200 in 2.5 more seconds and at x: +200 in 3 more seconds at the same time. The cat jitters or ends up somewhere weird — definitely not where Aljay expected.
This is the trap of two-ears-that-fight. Both receivers change the same property (the cat's x-coordinate) and they're running simultaneously.
One fix: use go to x: () y: () instead of glide. go to is instant, so it can't fight with itself — the most recent press just wins.
when I receive (go left v)
go to x: (-200) y: (0)
when I receive (go right v)
go to x: (200) y: (0)
A better fix (which we'll meet next lesson): use broadcast (go left v) and wait at the sender so the next broadcast can't fire until the current glide is done. The and wait variant is the topic of L02-22.
Recap 3 min
You learned that when I receive (message v) is a hat block — same family as when ⚑ clicked. A sprite can have many of them, one per message it cares about, and each is its own independent script. The receiver doesn't know or care which sprite sent the broadcast — listeners and senders meet through the shared message name only. Even the Stage can be a listener. Two ears on the same sprite that fire at the same time run in parallel — which is great unless they fight over the same property, which is exactly what broadcast and wait (next lesson) is designed to fix.
- When I receive
- A yellow Events hat block that starts a script when a matching broadcast arrives. Cannot have blocks above it — it's the top of its stack.
- Receiver
- Any sprite (or the Stage) that has at least one matching when I receive hat. A broadcast may have zero, one, or many receivers.
- Hat block
- Any block with a curved top — flag, key, click, message, etc. Starts a new script when its trigger fires. Nothing snaps above a hat.
- Parallel scripts
- Two or more scripts running at the same time. Happens whenever multiple hats fire simultaneously. Scratch handles this automatically; you only need to worry when two parallel scripts change the same thing.
- Cross-sprite communication
- Sprites that influence each other through broadcasts, without one calling the other directly. The whole point of the broadcast system.
Homework 2 min
The Three-Ear Bunga. Build a sprite with three receiver hats and a controller sprite that fires the cues.
- New project. Delete the cat. Add a Bunga (Flower) sprite and a Button sprite.
- On the Button, create three messages from the broadcast dropdown:
bloom,wilt,shake. - The Button has three hats, one per key: when [b v] key pressed → broadcast (bloom v); when [w v] key pressed → broadcast (wilt v); when [s v] key pressed → broadcast (shake v).
- On the Bunga, three receiver hats: when I receive (bloom v) sets size to 150%; when I receive (wilt v) sets size to 50%; when I receive (shake v) repeats change x by (10) + change x by (-10) a few times.
- Add a flag-hat on the Bunga that resets it to size 100% at x: 0, y: 0 — so each flag-click starts clean.
- Add one more ear on the Stage — when I receive (shake v) + play sound (pop v) until done. Now the Stage also reacts to the shake cue.
Save as HW-L2-21-Three-Ears.sb3. Press b, w, s a few times each. The Bunga should bloom, wilt, and shake, and the Stage should pop on every shake.
Bring back next class:
- The
.sb3. - Your answer to: "What happens if you press
bandsat exactly the same instant? Try it three times. Is the result always the same?"
Heads up for next class: SCR-L02-22 meets broadcast (message v) and wait — the variant of broadcast that pauses the sender until every listener has finished. The cure for fighting ears.