Learning Goals 3 min
By the end of this lesson you will have built and you will be able to:
- Combine broadcast and wait with when I receive to make two sprites take turns speaking — one waits politely while the other talks.
- Use four well-named messages (
a-done,b-done,a-done-2,b-done-2) to structure a scripted back-and-forth. - Add a small wave costume animation with next costume so each sprite has visible body language at the end of its line.
Warm-Up — two friends, one whistle each 7 min
Imagine Aisyah and Daniel at the gerai. Aisyah speaks first. Daniel waits — without interrupting — until she's finished. Then he answers. Then Aisyah answers him. They take turns, and nobody talks over anybody.
Now imagine you have to script that conversation in Scratch. Each sprite has its own script. The tricky bit is the handoff — how does Daniel know Aisyah has finished her line, so he can start his?
Reveal the answer
Each sprite ends its line with a broadcast (… v) and wait — a small "I'm done, your turn" whistle. The other sprite has a when I receive (… v) hat that listens for that exact whistle. When the whistle arrives, the listener starts its line. When the listener finishes, it sends its own whistle back. That's the whole pattern — and it's the whole project today.
Predict this. If Aisyah's first whistle is called a-done and Daniel's first whistle back is called b-done, how many different whistles do we need to handle two lines each (four lines total)?
Reveal the answer
Four. a-done (Aisyah finished line 1), b-done (Daniel finished line 1), a-done-2 (Aisyah finished line 2), b-done-2 (Daniel finished line 2). Each line in the conversation gets its own end-of-line cue. That way the script is unambiguous — there's exactly one way for Aisyah and Daniel to take turns.
New Concept — the conversation pattern 10 min
This lesson combines everything in cluster D. You've met all four pieces already:
- broadcast (… v) from L02-20 — send a cue and keep going.
- when I receive (… v) from L02-21 — a hat that fires on a named cue.
- broadcast (… v) and wait from L02-22 — send a cue, then pause until every listener finishes.
- Naming hygiene from L02-23 — pick from the dropdown, never retype.
The capstone today is the cleanest possible use of all four: two sprites taking turns, with a tiny wave at the end of each line so the conversation looks alive.
Why "and wait" matters here
If Sprite A uses a plain broadcast (a-done v) (no wait), its script continues immediately. Sprite A would start its second line at the same instant Sprite B starts its first. They'd talk over each other.
If Sprite A uses broadcast (a-done v) and wait, the script pauses. Scratch checks: who is listening for a-done? Sprite B. Has Sprite B's whole script for a-done finished? Not yet. Wait. Now yes. OK, Sprite A continues. That pause is what makes the turn-taking work.
Four messages, named for events
Following the L02-23 rule, each message describes what just happened, not what should happen next:
a-done— Sprite A finished its first line.b-done— Sprite B finished its first line.a-done-2— Sprite A finished its second line.b-done-2— Sprite B finished its second line.
Notice none of them say "now talk" or "now wave". The cue announces the event; each listener decides its own reaction.
The wave animation
Most Scratch sprites ship with two costumes already (e.g. aisyah-a and aisyah-b, or any two-pose character). A wave is just three or four quick next costume blocks with a tiny wait (0.15) seconds between them. The body looks like it's moving, even though it's only flipping between two pictures.
next costume
wait (0.15) seconds
next costume
wait (0.15) seconds
next costume
wait (0.15) seconds
next costume
Worked Example — build the conversation 18 min
Open Scratch. Two sprites, four messages, ten minutes of careful clicking. Pick from the dropdown — never retype.
a-done, b-done) so the two take strict turns.Step 1 — Set the stage
New project. Delete the default Cat. Pick a two-pose character for Sprite A (try Aisyah from the library, or any sprite with two costumes — Avery, Devin, Dorian, Glow Star all work). Add a second two-pose character for Sprite B (try Daniel, or any other two-pose sprite). Place A roughly at x: -120, y: -40 and B at x: 120, y: -40 so they face each other.
Step 2 — Create all four messages up front
On Sprite A, drop one broadcast (message1 v) just to use the dropdown. Click ▾ → New message… → type a-done → OK. Repeat three more times for b-done, a-done-2, and b-done-2. Now every dropdown in the project — on both sprites — will already contain all four names.
Why up front? Because for the rest of the lesson you will always be picking from the dropdown, never typing. That's the rule from L02-23.
Step 3 — Sprite A's script: greeting + handoff
Click Sprite A. Throw away the broadcast you used in Step 2 and build the real script:
when flag clicked
say [Hi!] for (2) seconds
broadcast (a-done v) and wait
say [Want to play?] for (2) seconds
broadcast (a-done-2 v) and wait
Step 4 — Sprite B's first response
Click Sprite B. Add a hat block that listens for A's first end-of-line cue, says hello back, and broadcasts its own end-of-line cue.
when I receive (a-done v)
say [Hey!] for (2) seconds
broadcast (b-done v) and wait
a-done, replies, sends b-done.Step 5 — Sprite B's second response
Still on Sprite B, add a second hat — a separate script — for A's second line.
when I receive (a-done-2 v)
say [Yes! Jom main!] for (2) seconds
broadcast (b-done-2 v) and wait
a-done-2, replies in Malaysian English ("jom main" = "let's play"), sends b-done-2.Step 6 — First test: click the flag
Click the flag. You should see:
- Sprite A says "Hi!" for 2 seconds.
- Sprite B says "Hey!" for 2 seconds.
- Sprite A says "Want to play?" for 2 seconds.
- Sprite B says "Yes! Jom main!" for 2 seconds.
Total: about 8 seconds, with clean turns and no overlap. If two sprites talk at the same time, you forgot the and wait on a broadcast — go back and check.
Step 7 — Add the wave to Sprite A's end-of-line
The conversation works, but the sprites are statues. Let's add a wave so each one moves when it finishes a line. Sprite A waves at the end of each of its lines — easiest way is to give each line a tiny wave block of its own. Update Sprite A's script:
when flag clicked
say [Hi!] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (a-done v) and wait
say [Want to play?] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (a-done-2 v) and wait
Step 8 — Add the wave to Sprite B
Do the same for both of Sprite B's reply scripts.
when I receive (a-done v)
say [Hey!] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (b-done v) and wait
when I receive (a-done-2 v)
say [Yes! Jom main!] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (b-done-2 v) and wait
Step 9 — Test the full thing
Click the flag. Each sprite speaks, then waves, then hands off. The other sprite speaks, then waves, then hands back. Four lines, four waves, no overlap. About 9–10 seconds total.
Step 10 — Audit the dropdowns
This is the last and most important step — and the one most students skip. Click any broadcast dropdown on any sprite. You should see exactly four message names: a-done, b-done, a-done-2, b-done-2. If you see a fifth one (like A-done or a done with a space), you retyped somewhere. Use right-click → Edit message → Delete to clean it up.
What you just built: the smallest possible scripted scene with proper turn-taking. Every cutscene in every adventure game, every NPC dialogue in every RPG, every "press space to continue" story scene — they all use this exact pattern. You now know it.
Try It Yourself — extend the conversation 12 min
Goal: Add a third line for each sprite, so the conversation runs A → B → A → B → A → B. You'll need two new messages: a-done-3 and b-done-3. Create them from the dropdown once, then pick them everywhere else.
say [See you tomorrow!] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (a-done-3 v) and wait
b-done-3 broadcast.Think: The pattern doesn't get any harder as the conversation gets longer. Each new line adds one new message on each side. The hat-block listener is always one new script on the other sprite.
Goal: Add a third character — Priya — who only speaks once, after Sprite B's first reply. Priya listens for b-done and says "Boleh I join?" ("Can I join?" in Malaysian English). Sprite A's second line should only start after Priya is done — which means Priya needs to broadcast her own end-of-line cue, and Sprite A needs to wait for it.
when I receive (b-done v)
say [Boleh I join?] for (2) seconds
next costume
wait (0.15) seconds
next costume
broadcast (priya-done v) and wait
Think: Sprite A's first line currently ends with broadcast (a-done v) and wait. After that wait, A goes straight to "Want to play?". To insert Priya, you don't change A's script at all — you just add Priya's hat block that fires on b-done. But to make A wait for Priya too, change A's second broadcast logic: after B's reply, A is already in the gap. The cleanest fix is to have B broadcast b-done with and wait, which it already does — and Priya's hat listens for that. As long as Priya finishes before A's wait on a-done finishes, it works. (Bonus question for the homework: is that actually true?)
Goal: Add a backdrop change halfway through. When Sprite A finishes its first line, the Stage should switch from a daytime backdrop to a sunset backdrop, before Sprite B replies. Use the Stage's own when I receive (a-done v) hat — the Stage can listen for broadcasts too.
when I receive (a-done v)
switch backdrop to [sunset v]
a-done message that Sprite B already listens for. Two listeners, one message — perfectly fine.Think: Because Sprite A used broadcast (a-done v) and wait, A waits for both the Stage script and Sprite B's script to finish before continuing. That's the magic of broadcast-and-wait — one sender, many listeners, all of them block the sender. You've just turned a two-sprite conversation into a three-actor scene without changing a single block on Sprite A.
Mini-Challenge — the conversation that ran twice 5 min
"Aisyah's echo bug"
Aisyah built the conversation, but tried to save messages by using just one handoff cue called turn done for everything. Here are her scripts:
when flag clicked
say [Hi!] for (2) seconds
broadcast (turn done v) and wait
say [Want to play?] for (2) seconds
broadcast (turn done v) and wait
when I receive (turn done v)
say [Hey!] for (2) seconds
broadcast (turn done v) and wait
turn done for its own handoff.Click the flag mentally. The conversation goes terribly wrong. What does Aisyah actually see — and what's the smallest fix?
Reveal one valid solution
Two bugs at once, both caused by the shared name.
Bug 1: When Sprite A broadcasts turn done the first time, Sprite B starts its reply — and Sprite B itself also has a listener for turn done, because every when I receive hat with that name fires. So Sprite B's reply script tries to start a fresh copy of itself every time anyone (including itself) broadcasts turn done. You get overlapping "Hey!" speech bubbles.
Bug 2: When Sprite B finishes its reply and broadcasts turn done, Sprite A doesn't have a hat for it — A is waiting on the same message it just sent. The "and wait" sees no new listener and returns immediately. But Sprite B's listener fires again. The whole thing snowballs.
The fix is the lesson: each end-of-line cue needs its own name. a-done for A's lines, b-done for B's lines. A listens for b-done; B listens for a-done; nobody listens for their own broadcast. The conversation runs once, cleanly:
when flag clicked
say [Hi!] for (2) seconds
broadcast (a-done v) and wait
say [Want to play?] for (2) seconds
broadcast (a-done-2 v) and wait
when I receive (a-done v)
say [Hey!] for (2) seconds
broadcast (b-done v) and wait
Same number of blocks — different names. The names do the structural work. That's why naming hygiene (L02-23) and the conversation pattern (today) live next to each other in the syllabus.
Recap 3 min
You built your first scripted scene with two sprites taking turns. The pattern is the same one every cutscene, dialogue tree, and NPC conversation uses: each sprite ends its line with a broadcast (… v) and wait whose name is unique to that line, and the other sprite has a matching when I receive (… v) hat that fires on it. The and wait is what makes the turn-taking work — without it, every sprite would talk at once. Four well-named messages (a-done, b-done, a-done-2, b-done-2) carry the whole structure. A tiny costume flip after each line makes the sprites feel alive. This is the cluster-D capstone — every broadcast lesson in Level 2 collapses into this one pattern, and you'll reuse it in every multi-scene project from here on.
- Scripted conversation
- Two or more sprites taking pre-written turns, each ending its line with a broadcast-and-wait whose unique name signals "I'm done". The opposite of an improvised AI dialogue — every line, in order, every time.
- Handoff cue
- A broadcast whose only job is to say "I just finished my line, your turn now". Today's project uses four:
a-done,b-done,a-done-2,b-done-2. - Wave animation
- A tiny costume animation made of two or four next costume blocks with short wait (0.15) seconds in between. Cheap, fast, makes a static sprite feel alive at the end of a spoken line.
- Cluster-D capstone
- The final lesson in the broadcasts cluster (L02-20 through L02-24). It combines broadcast, when-I-receive, broadcast-and-wait, and naming hygiene into one project that you can extend forever.
- One sender, many listeners
- A single broadcast can be heard by every sprite — and the Stage — that has a matching hat. broadcast (… v) and wait waits for all of them to finish, which is how the stretch task adds a backdrop change without changing the sender's script.
Homework 2 min
Your own three-line scene. Build a fresh project — not an extension of today's. A new place, new characters, a complete tiny scene.
- Pick a setting in Malaysia. Suggestions: the school canteen at recess, a pasar malam stall, the LRT platform, the badminton court, an aunty's house at Hari Raya open house.
- Pick two sprites (or use letters/objects — the Drum kit sprites and Microphone work fine, even a Pencil and Eraser).
- Write the conversation on paper first. Three lines each, alternating. Six lines total.
- Create six messages up front:
a-done,b-done,a-done-2,b-done-2,a-done-3,b-done-3. Pick from the dropdown every other time. - Use broadcast (… v) and wait for every handoff. No plain broadcasts.
- Add a wave (or any other two-costume motion) after each spoken line.
- Save as
HW-L2-24-My-Scene.sb3.
Bring back next class:
- The
.sb3file. - The six-line script written on paper (or typed in a note), in order.
- Your answer to: "Open the broadcast dropdown on any block in your project. How many message names are there? If it's more than six, where did the extras come from — and what would you do to clean them up?"
Heads up for next class: SCR-L02-25 opens cluster E (multi-scene stories). The conversation pattern you built today becomes the inside of each scene — and broadcasts are how you'll jump between scenes by switching backdrops. Same tools, bigger project.