Scratch 03 · Build an interactive story

A fox and robot exchange speech bubbles.

Scratch lesson 3 of 10 · Beginner · About 35 minutes

Stage a two-character mystery. Start it with the space bar, send a message between characters and switch scenes once a clue is revealed.

What you’ll make Create a short story where the player presses space, two characters speak in turn and the backdrop changes at the right moment.

Get ready

Open the Scratch editor (opens in a new tab) and start a new project.

  • Start a fresh Scratch project and title it The Lantern Clue. Use the starting sprite and add one more. Rename the first sprite Scout and the second Guide in their sprite name fields.
  • Select the Stage and open Backdrops. Add a second backdrop from the library or paint your own. Rename the two backdrops Workshop and Garden in the name field above the backdrop canvas. They can be simple colours or pictures, as long as they are easy to tell apart.
  • Return to Code. Before each step, click the named sprite thumbnail so you put the blocks on the right character. Scout will run the story. Guide will wait for a message.

To keep your project, choose File → Save to your computer in Scratch.

Begin the story. Character one speaks. → Send a message. Give the next character a cue. → Change the scene. Show what happens next.
Project flow · Begin the story → Send a message → Change the scene

Build it in Scratch

Choose the sprite named above each stack. The colours help you find the block categories. Indented rows sit inside the block above. Follow the end marker to see where each loop or condition closes.

1. Set the opening scene on Scout

Select Scout. Join the green-flag event, switch backdrop to [] from Looks and the Motion position block. Use the menu to pick Workshop. Add the plain say [] block and tell the player to press space. The plain speech block keeps its bubble until another speech block changes or clears it, which is useful for a start prompt.

Block stack for Scout
when green flag clicked
switch backdrop to [Workshop]
go to x: (-125) y: (-45)
say [Press space to start.]

2. Give Guide a reset too

On Guide, start a new green-flag stack and position the sprite on the right. Attach the plain say [] block and delete its text so the speech box is empty. This clears a lingering bubble when the player restarts. Click the flag and check the two starting positions. The two green-flag stacks each run on their own sprite.

Block stack for Guide
when green flag clicked
go to x: (125) y: (-45)
say []

3. Send the clue request on Scout

On Scout, create a separate stack using when [space] key pressed from Events. First switch to Workshop so tapping space after the story ends starts that scene again. Add Scout's question in a timed speech bubble. Attach broadcast [] and wait. Open its menu, choose New message and name it share clue. A broadcast is a message scripts can listen for. The version with ‘and wait’ pauses Scout until the receiving script finishes.

Block stack for Scout
when [space] key pressed
switch backdrop to [Workshop]
say [Where did the lantern go?] for (2) seconds
broadcast [share clue] and wait

4. Make Guide reply when the message arrives

Select Guide. Add a separate when I receive [] stack from Events, and choose the same share clue message. Attach a timed speech block. Now click the flag and tap space once. Listen for the order. Scout's bubble should disappear before Guide responds. Guide's response should stay on screen for two seconds.

Block stack for Guide
when I receive [share clue]
say [Follow the trail into the garden!] for (2) seconds

5. Move the story into the garden

Return to Scout and finish the space-key stack by adding the last two blocks in the diagram. The switch to Garden goes directly below the broadcast. It runs only when Guide has finished speaking. Give Scout a closing line so players know the scene change is part of the story.

Block stack for Scout
when [space] key pressed
switch backdrop to [Workshop]
say [Where did the lantern go?] for (2) seconds
broadcast [share clue] and wait
switch backdrop to [Garden]
say [There it is, by the gate!] for (2) seconds

Test your project

  1. Click the flag. Look for Workshop, two sprites in their starting positions and Scout's start prompt.
  2. Tap space once and wait for the story to finish. Check the order is question, clue, scene change, closing line.
  3. After the ending, click the flag again. Workshop and the prompt should return. Tap space again to replay.

If something goes wrong

Scout asks the question, but Guide stays silent.
On Guide's when I receive block, pick the exact same share clue message from the menu. Verify Guide's speech block is snapped beneath it.
The backdrop changes while Guide is still speaking.
Check Scout uses broadcast and wait and that the Garden switch is underneath it. Ordinary broadcast continues without waiting.
The project ignores the space bar.
Click the flag or the stage to move focus out of the text field you were editing. Tap space once and check that Scout's event menu says space.

Make it your own

  • Give Guide a second line at the garden gate. Create a new broadcast for that line and decide where Scout should send it.
  • Add a third backdrop for an epilogue. Plan which message or finishing line should come before it.

What you’ve learned Events tell scripts when to start. Broadcasts let one sprite cue another, and broadcast and wait keeps the conversation in order.