Scratch is a fun and creative learning platform for kids who are curious about building games and applications. They can use their imagination to add and customize their projects. 

In this tutorial, I’ll show you how to make a timer in Scratch. We will code a countdown timer and a stopwatch. You can add these timers to existing projects or your new project for a dynamic experience.

To learn Scratch with the experts, join our top-rated Scratch classes for kids

What is Scratch

Scratch is a drag-and-drop coding language that helps kids learn coding fundamentals as well as develop critical thinking, problem-solving, and logical reasoning skills.

It’s a coding playground that teaches kids in a hands-on and accessible way. It’s safe, fun, and completely free.

Scratch is easy to access through any browser and has a supportive community where students can share and remix projects and games. It’s one of the best ways, especially for young kids, to learn the foundations of programming.

What is a timer in Scratch?

Timers are a component of a program or game that measures time in specific intervals. 

A timer can be used to delay actions, limit the duration of actions, or allow actions to continue for a total amount of time.

You can add a timer to count up or count down. Timers can be used in various projects, from simple games to complex animations. Each project may require a different type of timer.

In Scratch, timers are used to control the execution of command blocks or schedule actions to occur at specific intervals. 

Timers require a trigger to start or stop. For example, your timer may start when the green flag is clicked and stop once it reaches a certain amount of time. Or maybe your timer starts with a new level and stops when the sprite is clicked.

Timers in Scratch can be created using custom variables or the built-in timer variable.

Custom variable

You can create a timer in Scratch by creating a custom variable to store the time. 

create a custom variable in Scratch

Built-in variable

The timer variable is a feature in Scratch that records how many seconds have passed since the last time the green flag was clicked or the timer was reset. 

Built-in timer variable

Why add a timer? 

Timers are a way to make your game or project more dynamic and engaging. 

In a game, a timer can present a challenge. Let’s say you only have 5 minutes to complete a level, this helps structure the game and adds difficulty.

For apps, a timer may be used to track goals. Think of a running app where you track the number of miles you can in one day. 

There are a variety of ways timers are useful in a project or game including:

Scheduling actions

Timers can schedule specific actions to happen at predetermined intervals, such as executing code or triggering an event.

Breaking down tasks

Timers help break down challenging tasks into smaller, more manageable chunks. This prevents users from getting overwhelmed and maintain a sense of progress.

Adding stakes

Timers add stakes to a game such as by making players lose if they run out of time. For example, players could try to get as many points as possible or solve a puzzle before the timer runs out.

Monitoring performance

Timers can be used to monitor the performance of code, such as measuring how long it takes to run. 

How to Make a Countdown Timer in Scratch

A countdown timer starts at a certain number and counts down, usually ending at 0.

In our Flying Space Cat game, we can make the game more difficult (and fun!) by limiting the amount of time players have to accomplish the goal of collecting crystals. 

Remix this project to add a timer to it. You can also try the full Flying Space Cat tutorial

Let’s add a countdown timer to limit the players to 60 seconds.

  1. Start the timer
  2. Countdown every 1 second
  3. Add the next action
  4. Customize your timer

Step 1 Start the timer

We will set the timer to start when the game starts, when we click the green flag. 

when green flag clicked block

The time starts at 60 seconds. Since the time changes, use a variable to hold this value. 

make a variable block

Press the green flag to see the time displayed.

Step 1 start scratch timer

Step 2 Countdown every 1 second

Every second, the time decreases by 1 until it reaches 0. Then the game is over.

repeat loop

Click the green flag to watch your timer countdown!

Step 2 timer counts down

Step 3 Add the next action

When the time runs out, or reaches 0, the loop and the game ends.

Decide what happens when the time runs out. In our game, the “Game Over” message displays.

broadcast game over
completed time block

Run down the time to see the Game Over message.

Step 3 game over message

Your timer is complete. See and remix the full game code here

Step 4 Customize your timer

You can easily customize this timer by changing these features:

How long is the countdown? 

Change the 60 in “Set Time to” block to another number.

What happens in your app after the time runs out? 

Add that code beneath the “Repeat Until” block.

How fast does the timer countdown? 

Change the time in “wait 1 seconds” and “change Time by -1” to countdown faster or slower.

How to Make a Stopwatch in Scratch

We can also create a stopwatch in Scratch. A stopwatch measures the time that has elapsed from when it’s started. It’s often used when we need precise time measurements like in a race where only seconds separate the winners and losers.

Scratch has a built-in timer variable that tracks to the microsecond how much time has passed since the last time the green flag was clicked or the timer was reset. 

I’ll show you how to start and stop a timer here. 

Add a Stopwatch To “A Unicorn Sighting”

You are hanging out at the beach and see an incredible sight, a white unicorn running across the beach! Build a timer to track how long your unicorn sighting is, it will be different every time. Start the timer when you see the unicorn and stop it when it disappears.

Remix this project to add a stopwatch to it. You can also see the completed A Unicorn Sighting.

Now, let’s add a stopwatch to track the time.

  1. Create a button sprite
  2. Set the stopwatch to 0 to start
  3. Change the button when it’s clicked
  4. Control the start and stop button

Step 1 Create a button sprite

We need one sprite, this is a start and stop button. 

Choose a sprite
create a start and stop costume
completed start and stop costume in scratch

You should see the button in your preview screen!

Step 2 Set the stopwatch to 0 to start

Add this code to your button sprite. We will set the stopwatch to 0 when the application is started.

when green flag clicked

Since the time changes, use a variable to hold this value. 

make a time variable in scratch

Press the green flag to see the stopwatch set to “start” and time variable to 0. Make sure you are seeing the right button and time.

set time and button

Step 3 Change the button when it’s clicked

When the start button is clicked, it will change to stop and vice versa.

next costume block

Try clicking on the sprite, the costume should change when you click it. 

step 3 start and stop button

Step 4 Control the start and stop button

Now, we need to control the time using the start and stop buttons.

Create two if statements based on what the button is showing. The first if statement is when the start button is clicked.

if then block
start costume if then code block

The second if statement is when the stop button is clicked.

stop if then code block
completed stop if then code block
Step 4 start and stop loop

Click the start button and see if it works! Watch the unicorn run across the screen and capture the time.

Now, you have a simple stopwatch to track the time. 

Try creating your own stopwatch or adding one to your next project. There are plenty of ways to customize it and improve on this simple stopwatch. 

Download Free Printable Scratch Coding Tutorials PDF

Try adding a timer to these Scratch games. Download a full PDF tutorial for the Rocketship Landing game and Flying Space Cat game.

Learn How to Make Games in Scratch

Making games in Scratch is a great way for kids to build a foundation in programming and also practice analytical thinking, computational thinking, problem-solving, and logical reasoning. 

Kids, ages 8-10, who want to learn more about Scratch coding will love the live, online classes at CodeWizardsHQ. We offer a structured curriculum with project-based learning and expert instructors who support students every step of the way. Enroll today to get started.

They’ll build the coding fundamentals they need to move on to text-based programming in Python and JavaScript. It’s a complete coding program that provides everything your child needs to learn to code.

Learn to make games in Scratch in our top-rated coding classes for kids.