Learning Goals 3 min
By the end of this lesson you will be able to:
- Wrap a play sound [drum v] until done block inside a forever loop to make a non-stop drumbeat.
- Explain why play sound until done works better than start sound for a clean loop.
- Build a background loop on one sprite while a second script keeps doing other things.
Warm-Up 7 min
Last lesson (Arc 3/5) you shaped sounds with volume and pitch. Today (Arc 4/5) you'll loop them. One short market sound, repeated forever, becomes the ambient backdrop for the whole Pasar Pagi scene.
Quick-fire puzzle
Faiz wrote this script and clicked the green flag. What did he hear?
when flag clicked
forever
play sound [Drum Beat v] until done
end
Reveal the answer
A drum beat that never stops. As soon as one beat finishes, the loop comes round again and plays the next one. No gaps. The drum will keep playing until Faiz clicks the red stop sign.
This is the simplest possible background music loop in Scratch.
New Concept — sound + forever = loop 15 min
Think of forever as a tape that rewinds itself. The blocks inside run from top to bottom, then start over, again and again. Put one Sound block inside, and you've made a tape loop — perfect for background drums or chatter.
Blocks at work today
| Block | Category | What it does |
|---|---|---|
| forever | Control | A c-block. Runs every block inside, top to bottom, then starts over — without stopping. |
| play sound [drum v] until done | Sound | Plays one beat, pauses the script until that beat ends. Perfect inside forever — no gaps, no overlaps. |
| start sound [drum v] | Sound | Plays the beat and moves on immediately. Inside forever with no wait — you get hundreds of overlapping beats per second. Messy. |
| wait (0.5) seconds | Control | Pauses for the chosen time. Use with start sound when you want manual control of timing. |
Two ways to loop a sound
Way 1 — clean loop using until done:
when flag clicked
forever
play sound [Drum Beat v] until done
end
Way 2 — manual timing using start sound + wait:
when flag clicked
forever
start sound [Drum Beat v]
wait (0.5) seconds
end
Way 1 is easier and matches the natural length of the sound. Way 2 gives you control — for example, faster than the sound itself plays (overlapping echoes) or slower (gaps of silence between beats).
Why it matters
Real games and films have background audio — a soft heartbeat in a horror scene, market chatter behind a story, a drum loop during a chase. With forever wrapped around one Sound block, your project has its own soundtrack. The student can feel the difference between a silent game and a noisy one.
Worked Example — the dancing cat with a drumbeat 15 min
Open Scratch. The cat is on the Stage. We'll add a market sound, build a forever loop on the cat, then add a second script that moves the cat side to side while the sound loops.
Step 1 — Add the drum sound
Click Sounds tab → green "+" button → magnifying glass → Music Loops → choose Drum Beat. Switch back to the Code tab.
Step 2 — Build the loop
Drag when flag clicked into the Script Area. Drag a forever below it. Then drag play sound [Meow v] until done inside the forever's mouth. Change the dropdown to Drum Beat.
when flag clicked
forever
play sound [Drum Beat v] until done
end
Step 3 — Add a second script on the same cat
Below or beside the first stack, drag another when flag clicked hat. (Yes, two hats — that's fine. They start at the same time.) Then build this:
when flag clicked
forever
move (10) steps
if on edge, bounce
end
Step 4 — Click the flag
Both scripts start together. The drum plays. The cat marches. The two scripts run side by side on the same sprite — Scratch's superpower.
Step 5 — Try the messy version (just to hear it)
Temporarily swap play sound until done for start sound [Drum Beat v] (no wait). Click the flag. You'll hear a noisy mess — hundreds of beats playing over each other. Switch back to until done when you've heard the difference.
What changed: compared to L01-37 where you played sounds once, your project now has a soundtrack — looping audio that keeps going while everything else carries on.
The full assembled stacks (your reference)
when flag clicked
forever
play sound [Drum Beat v] until done
end
when flag clicked
forever
move (10) steps
if on edge, bounce
end
Try It Yourself — three small builds 12 min
Goal: Loop the meow forever. (You don't even need to add a new sound — Meow is already there.)
when flag clicked
forever
play sound [Meow v] until done
end
Think: After ten meows you'll want to stop! Click the red stop sign on the Stage to end the loop.
Goal: Build a "kettle then drum" two-beat loop. The kettle whistles first, then the drum beats, then it repeats — forever.
when flag clicked
forever
play sound [kettle v] until done
play sound [Drum Beat v] until done
end
Think: Two sounds inside the loop play in order, then the loop comes back to the start. The pattern repeats forever. Add a third sound to see the rhythm grow.
Goal: Build the manual-timing version: start sound + wait 0.3 seconds in a forever. The fast-tempo drum. Then try wait 1, then wait 2. Listen to the rhythm change.
when flag clicked
forever
start sound [Drum Beat v]
wait (0.3) seconds
end
Think: When the wait is shorter than the drum sound itself, beats overlap and the rhythm sounds urgent. When the wait is longer, you get gaps of silence. You set the rhythm, not the sound's natural length.
Mini-Challenge — the dancing cat 5 min
"Cat dances to the gendang"
Build a project where the cat dances to a drum loop. The drum plays forever in the background. The cat moves and changes costume in time with the beat. Gendang is the traditional Malaysian drum — let it set the rhythm.
It works if:
- A drum sound plays forever after the green flag click.
- The cat is also doing something on screen the whole time (moving, turning, swapping costumes, growing/shrinking — any of L01-23 to L01-29 will do).
- Both behaviours are on the same cat sprite, in two different scripts.
- Clicking the red stop sign stops everything.
Reveal one valid solution
when flag clicked
forever
play sound [Drum Beat v] until done
end
when flag clicked
forever
next costume
wait (0.3) seconds
end
The first script loops the drum. The second loops a costume change every 0.3 seconds — the cat appears to dance in time with the beat. Two scripts, both starting on the same hat block, both running forever.
Recap 2 min
Today you wrapped a Sound block in forever to make a background loop. Until done gives you a clean natural loop. Start sound with a manual wait gives you custom rhythm. One sprite can have many scripts — so the loop keeps running while the cat dances.
- Loop
- Code that runs again and again. Forever loops never stop on their own; the red stop sign ends them.
- Background loop (sound)
- A short sound played in a forever loop. Sounds like continuous music or chatter.
- until done vs start sound
- Until done pauses the script for the sound's full length. Start sound moves on immediately, useful with a manual wait.
- Side-by-side scripts
- Two or more scripts on the same sprite, each with its own hat block. They run at the same time when their triggers fire.
Homework 1 min
The endless market. Pick three short sounds from the library (kettle, bell, drum — or any others you like). Build a forever loop that plays all three in order, on repeat. Then add a second script that makes the cat say something every few seconds while the loop continues.
- Sounds tab → add three sounds.
- Build a forever loop with all three sounds inside, using play sound until done for each.
- Build a second flag-clicked script that uses wait and say to put a message on the cat every few seconds.
when flag clicked
forever
play sound [kettle v] until done
play sound [Drum Beat v] until done
play sound [Bell Toll v] until done
end
when flag clicked
forever
say [Selamat datang!] for (2) seconds
wait (3) seconds
end
Bring back next class:
- A screenshot of your Script Area showing the two scripts.
- Your own answer to: "What would happen if you wrapped the same sound in BOTH scripts at once, with no until done?"
Heads up for next class: SCR-L01-39 is a Project. You'll build a Pasar Pagi (morning market) sound story using everything from this cluster.