Codingal > Coding for kids > Blogs > Scratch Threads: Running multiple scripts simultaneously

Scratch Threads: Running multiple scripts simultaneously

Parul Jain on September 12, 2025

In the digital world, programming languages are often the torchbearers of a generation. Scratch in this way is a popular visual programming language that helps young learners, especially kids, dive into the world of coding in a fun and interactive way. 

One of the exciting features of programming with Scratch, is the ability to run multiple scripts simultaneously using something called threads. If you’ve ever played a game in Scratch and seen different actions happening at once like let’s say a character moving while music is playing that’s thanks to threads.

By the end of this article, you will be able to clearly understand what threads are in Scratch, how they work, and why running multiple scripts at the same time is so useful in coding. 

What Are Threads in Scratch?

In Scratch, threads allow different pieces of code (called scripts) to run simultaneously while also playing the game or performing other actions. Usually when you write a script, Scratch will follow the instructions at one go line by line. But in many cases, you might want multiple things to happen at once. For example, you might want a character to walk or perform other functions while another character is talking or doing something else.  

To make this happen, Scratch runs multiple scripts at the same time using threads. This ability is very important when creating interactive projects like games, animations, or even stories, where many things need to happen at once to keep things interesting and fun.

 

Why Use Threads in Scratch?

Using threads in Scratch opens up a lot of possibilities in your projects. Here are a few reasons why you’d want to use multiple scripts running at the same time:

  1. Make Your Projects More Interactive: Imagine creating a game where a character moves and enemies attack at the same time. Using threads allows you to control both actions together, making the game more interactive and exciting.
  2. Run Parallel Actions: Sometimes, you need different actions to happen together. For example, in a story project, you might want a background to change color while a character is speaking. Threads make this possible.
  3. Create Complex Animations: If you want characters or objects to move and react to events at the same time, threads are your best friend. Multiple animations can run together, making your project look more dynamic.
  4. Add Music or Sound Effects: You can play music or sound effects in the background while other scripts are running. This adds depth and fun to your projects, like adding sound effects to a game while characters are moving around.

 

How Threads Work in Scratch

Running multiple scripts at the same time in Scratch is easier than you might think. Let’s break down how it works:

1. Green Flag Events

In most Scratch projects, you use the “When Green Flag Clicked” block to start scripts. If you attach this block to multiple scripts, Scratch will run them all at the same time when the green flag is clicked. Each script becomes its own thread.

For example, you can have one script to make a character move, another to play a sound, and another to change the background color—all happening at the same time!

2. Broadcasting Messages

Another way to control multiple scripts at the same time is by using the “broadcast” block. Broadcasting sends a message that can trigger other scripts to start running. You can use the “When I Receive [message]” block to listen for these messages and run scripts based on what message is broadcast.

For example, if you’re making a game, you could broadcast a message when a character reaches a certain point, and that message could trigger other characters or objects to start moving.

3. Forever Loops

To keep scripts running continuously, you can use the “forever” block. This block repeats a set of actions over and over again without stopping. You can put this block in different scripts so they run together without stopping, like moving characters, playing music, or repeating animations.

 

Simple Examples of Using Threads in Scratch

Let’s look at a few examples to see how you can use threads in your Scratch projects.

Example 1: Moving a Character While Playing Music

Imagine you’re creating a simple animation where a character moves across the screen while music is playing. To do this, you can set up two scripts that run at the same time.

  1. First Script (For Moving the Character)
    • Use the “When Green Flag Clicked” block.
    • Add a “forever” loop and put in a block to move the character 10 steps.
    • Add a block to make the character turn or bounce when it reaches the edge.
  2. Second Script (For Playing Music)
    • Use another “When Green Flag Clicked” block.
    • Inside, use a “play sound until done” block to play music.

When you click the green flag, both scripts will run at the same time. The character will move across the screen while the music plays in the background.

Example 2: Changing Backgrounds While Characters Speak

Now, let’s say you’re creating a story where one character talks while the background changes color.

  1. First Script (For Changing the Background)
    • Use the “When Green Flag Clicked” block.
    • Add a “forever” loop that continuously changes the background color using the “next backdrop” block.
  2. Second Script (For Character Speech)
    • Use another “When Green Flag Clicked” block.
    • Use the “say [message] for 2 seconds” block to make the character say something.

Now, when the project starts, the background will keep changing colors while the character speaks at the same time.

 

Using Threads for Complex Projects

As you get more comfortable with Scratch, you can start creating more complex projects that use multiple scripts and threads. Here are a few ideas to inspire you:

  • Create a game with multiple moving characters: Each character can have its own script that controls its movement, actions, and interactions.
  • Design an interactive story: Characters can talk, move, and interact with each other while backgrounds and music change dynamically.
  • Make a quiz game: Use threads to show questions, track scores, and give feedback to the player, all happening in real-time.

 

Conclusion

Threads in Scratch are a powerful feature that let you run multiple scripts simultaneously, making your projects more interactive, dynamic, and fun. Whether you’re creating a game, an animation, or a story, using threads will help you add more depth and excitement to your work.

By learning how to control and manage multiple scripts, you’ll be able to create projects that engage and entertain your audience. So, start experimenting with threads in Scratch and see how far your creativity can take you!

 

Share with your friends

Try a free class