How to Create a Timer in Scratch, Game Design

Want to know how to create a timer in Scratch to set a time limit for a game? Follow the instructions to create a counter that tracks each second that passes. When a specific time is reached, the timer stops counting and the game ends.

create a timer in Scratch

Create a timer in Scratch to set a time limit for a game.

About the Scripts and Your Game

The directions listed below explain how to add a timer to an existing Scratch project. You may need to adjust the scripts slightly to suit your game.

About the Timer Variable

The script requires the use of a variable. A variable is a factor that can change. Create a timer variable. It will be used to hold the number of seconds.

Scratch Coding Blocks Used to Create a Timer

Scratch has several coding blocks that you will use to build the script:

change my variable by 1 Increase the (timer) variable by a specified amount.
Reset the (timer) variable to zero when a new game begins.
Display the timer variable to see the counter.
repeat until Do an action until the something specific happens (time limit is reached).
An operator that tests if the first value (seconds that have passed) equals the second value (time limit).

About the Timer Script

Before making the variable and building the script it is important to understand how the timer script works. Study the script below.

Does the timer equal 15? If no, wait 1 second and then increase the timer by 1 second. Repeat until the timer equals 15.

Code used to create a timer in Scratch.

Code used to create a timer in Scratch.

Game Design with a Timer Video

Watch the video to understand how a timer can be used to set a time limit for a game. If this is a coding project that you would like to make, TechnoCode has a game design coding unit. The instructions explain how to build scripts to have a player touch targets to earn points. The lessons also include a planning sheet, game consultant checklist, coding journal log, Scratch quiz, and marking sheet.

How to Create a Timer in Scratch

Create a Timer Variable

  1. Open the saved game project in Scratch.
  2. Select the sprite that you will use to track the time (it might be the player).
  3. From the Variables palette, click Make a Variable.
  4. Type timer as the variable name. Click OK.
  5. Create a timer variable.

    Create a timer variable.

  6. Select the timer variable to display it.
  7. Use your skills to build this script:
    How do you want the script to start? Notice that in the sample script below, it begins with when I receive play game. This is a broadcasted message that you may have already created. If the broadcast message was not made, you can use the when Go clicked Hat block. To learn about broadcasting read the post, How to Broadcast a Message in Scratch.
  8. Set the time limit using an Operator block.

    Set the time limit using an Operator block.

    Tip to Setting the Operator Coding Block:

    • View the Operator palette.
    • Drag __=50 into the if-then block if-then.
    • Edit the number of seconds to the time limit. For example, 15.
    • View the Variable palette. Add the timer. timer

    Test the Timer

  9. Play the game. When done, click Stop.
    • Does the timer increase when one second passes?
    • Does the timer stop when it reaches the time limit?

    Set the Timer to Zero When a New Game Begins

  10. Play the game again. Does the timer start at zero? NO, it doesn’t.
  11. Select the sprite that tracks the time.
  12. From the Variables palette, add set my variable to 0 to the start of a script. Click the Variable arrow and select timer.
  13. Add a coding block to reset the timer.

    Add a coding block to reset the timer.

    WHERE SHOULD THE CODING BLOCK GO? Notice where the set timer to 0 block is located in the script above. It was placed after the when Go clicked Hat block of an existing script. Look at your scripts. Where should it be placed in your game?

  14. Play the game again. The timer should start at 0.

Programming Lessons – Coding Units

Interested in Scratch lessons? Learn more about TechnoCode published by TechnoKids Inc. TechnoCode is a technology project that includes a teacher guide, workbook, and resource files. Use the instructional materials to teach a coding unit to students in Grades 6-9.


TechnoCode lessons

How to Keep Score in Scratch, Game Design

Do you need to keep score in Scratch? If yes, keep reading! The instructions explain how to track the points earned by a player each time it touches a target.

Keep score in Scratch

Keep score in Scratch

About the Game

The directions listed below explain how to add scoring to an existing Scratch project. The game should have with a player and target sprite. Several scripts must already be built. For example, the player should have a script that controls its movement using the mouse pointer. As well, the target should be programmed to show in random spots. If your game design is different, you may need to adjust the scoring system to suit your Scratch project.

NOTE: These instructions are modified from the technology project TechnoCode, published by TechnoKids Inc. TechnoCode has programming activities for kids. The lessons include a game design coding unit. The seven assignments, guide students step-by-step through how to construct an entire game. To support learning, the unit has a planning sheet, example videos, sample scripts, programming challenges, game consultant checklist, coding journal log, Scratch quiz, Treasure Hunt skill review, and Variable extension activity.

About the Score Variable

The script you will build requires the use of a variable. A variable is a factor that can change. You will create a score variable. It will be used to hold the number of points.

A coding block will be used to increase the score by a specified number of points. Increase the score by 1

Another coding block will reset the score variable to zero when a new game begins.reset the variable

About the Scoring System Script

Before making the variable and building the script it is important to understand how the scoring system script works. Study the script below.

Is the player touching the target? If yes, then increase the score by 2 points.

score script in Scratch

Code used to change the score in Scratch.

How to Keep Score in Scratch

Keep Track of the Score

  1. Open your saved game project in Scratch.
  2. Select the player sprite.
  3. From the Variables palette, click Make a Variable.
  4. Type score as the variable name. Click OK.
  5. new variable

    Create a score variable.

  6. Select the score variable to display it. score variable
  7. Use your skills to build this script.
    How do you want the script to start? Notice that in the sample script below, it begins with when I receive play game. This is a broadcasted message that you may have already created. If the broadcast message was not made, you can use the when Go clicked Hat block.
  8. Scratch scoring script.

    Set the number of points the player earns each time it touches the target.

    Tip to Setting the Sensor Coding Block:

    • View the Sensing palette.
    • Drag touching mouse pointer touching mouse pointer into the if-then block if-then.
    • Click the arrow and select the name of the target.

    Test the Scoring System

  9. Play the game. When done, click Stop.
    • Does the score increase each time the target is touched?
    • Are too many points added when the player touches a target?


  10. Use these tips to improve how the player scores points:
    • If too many points are added when target touched, add wait 1 seconds after change score.
    • Play a sound when the target is touched. You may need to trim the clip.

    Set the Score to Zero When a New Game Begins

  11. Play the game again. Does the score start at zero? NO, it doesn’t.
  12. Select the player sprite.
  13. From the Variables palette, add set my variable to 0 to the start of the player’s script. Click the Variable arrow and select score.
  14. Add a coding block with the score variable to reset the points.

    WHERE SHOULD THE CODING BLOCK GO? Notice where the set score to 0 block is located in the script above. It was placed after the when Go clicked Hat block of an existing script. Look at your scripts. Where should it be placed in your game?

  15. Play the game again. The score should start at O.

How to Broadcast a Message in Scratch

One method to direct the timing of events in a coding project is to broadcast a message in Scratch. Broadcasting sends a message to one or more sprites. The message is used to trigger a script to run.

broadcast a message in scratch

Broadcast a message in Scratch to direct the timing of events.

Scratch Coding Blocks to Broadcast a Message

Scratch is a coding app that introduces programming concepts to beginners. It uses blocks of instructions that are joined together to build scripts. Scratch has several coding blocks that can be used for broadcasting messages.

broadcast block Send a message to sprites.
broadcast and wait Send a message to sprites. Pause until all scripts triggered by the message have finished running.
when i receive Run a script when a broadcasted message is received.

When Should You Broadcast a Message in Scratch?

Broadcasting controls WHEN something happens – it is all about TIMING!

To understand its use, compare broadcasting to other computer-related tasks. For instance when video editing, objects are sequenced into a track on a Timeline. Or when designing a graphic story in PowerPoint, events are timed using the Animation Pane.

Scratch does not have a Timeline or Animation Pane. Instead, instructions are sequenced using coding blocks. Broadcasting blocks are used to set the timing of events in an animated scene, game, or story.

What can you do with broadcasting?

  • Hold a Conversation: Have sprites chat with one another in an animated scene or story. Broadcasting can prompt a character to answer a question. Or, cause a character to respond to something that was said.
  • Respond to Events: Use broadcasting to make a sprite react to an event. For example, a character may move or change appearance when something happens.
  • Produce Multiple Actions at the Same Time: Broadcasting can send a message to many sprites. This can cause several characters to do something at the same time. This enhances storytelling and holds viewer interest.
  • Control Game Play: Direct when a game begins using broadcasting. After the instructions appear on the screen a broadcasted message can launch the game. Use it to make targets appear or start a timer.
  • End a Game: Set what happens when a game is over. Use broadcasting to inform a player that the game has ended. For instance, you could display a message, such as GAME OVER. Broadcasting can also be used to stop game play. For example, you could hide targets to prevent the player from scoring more points.
  • Organize Scripts: Long scripts in Scratch cannot display on one screen. This makes them difficult to debug. A solution is to divide the script into smaller chunks using broadcasting. (TechnoCode, a recent STEM project by TechnoKids for middle school grades, has an extension activity that explains how to organize scripts using broadcasting. )

Plan to Broadcast a Message in Scratch

When using broadcasting it is a good idea to PLAN AHEAD:

  • Decide what you want to happen.
  • Once you have an idea, pick the sprite that will send the message. Who is in control of when an action happens?
  • Study the sprite’s script. To send the message at the right time, where should the broadcast coding block be placed?
  • Next, pick the sprite or sprites that will receive the message. What will they do when they receive the message?

Broadcasting Video

Watch the video to understand how broadcasting can be used in graphic storytelling. If this is a coding project that you would like to make, TechnoCode has an animated storytelling coding unit. The instructions explain how to build scripts to illustrate events. The lessons also include a story organizer, checklist, coding journal log, Scratch quiz, and story rubric.

How to Broadcast a Message in Scratch

  1. Select the sprite that will send a message.
  2. From the Events palette, add the block broadcast message1.
    broadcast block
  3. Click the arrow. Select New message.

    Pick New message.

  4. Type message name. Click OK.

    broadcast message

    To make it easy to identify, give a broadcast message the name of the action it will trigger.

  5. Place the broadcast block where you want to send the message. For example:

    broadcast warning sample

    Place the broadcast block into the script.

  6. Select the sprite that will receive the message.
  7. From the Events palette, add the block when I receive message1. Click the arrow. Select the message name from Step 4.
    when i receive

  8. Build a script that has the sprite do an action. For example:
  9. say warning

    What do you want the character to do when it gets the message?

TechnoCode and Broadcasting in Scratch

TechnoCode has many programming lessons for kids. One of the coding units teaches graphic storytelling. Detailed instructions explain how to use broadcasting to direct the timing of events. Another coding unit is about game design. Broadcasting is used by students to trigger the start and end of a game. Learn more about programming for kids.

broadcast game over

TechnoCode has lessons that teach broadcasting in storytelling and game design.

Free Holiday Ecards for Kids, Promote Digital Literacy

Are you interested in free holiday ecards for kids? Take a look at Greetings Island. It has a collection of greeting cards and invitations that can be downloaded, printed, or sent online.

Have your children or students send electronic greeting cards to friends, family, or classmates. Ecards are a great way to let someone know they are important. The gesture of sending a greeting card can mean a lot to the recipient. It can also help people stay connected.

Aside from the personal connection, sending ecards has educational value. Children can practice their writing skills. In addition, it is a relevant way to communicate digitally with others.

Free holiday ecards for kids are a great way to promote digital literacy.

Have Fun Sending Free Holiday Ecards for Kids

What makes Greetings Island a fun place to send ecards?

  • Fast and Easy! It is simple to make a card. The icons make it easy for young children to know which options to select.
  • Personalize It: Kids can upload a photo from their device. This adds a personal touch.
  • Suggested Greetings: Emerging writers can select from a bank of text options, without having to write their own message.
  • No Email Address Required: If the sender is too young to have an email address, they can download the ecard or print it instead.
  • Lots of Choice: Holiday greeting cards are fun to send – but so are Get Well, Good Luck, Teacher Appreciation, and Thank You cards. Greetings Island has a wide range of categories.

Tips for Getting Started with Sending Free Holiday Ecards for Kids

Before you start having everyone in your classroom or home sending ecards, you should visit Greetings Island first. Explore the site to view the selection in the online collection. This will help you to direct younger children to appropriate categories. For example, Funny has some cards that include text or images that might not be suitable for your age group. However, the category Kids has some great options that kids will like to send. If you want more options for sending ecards, check out Free E-Card Sites for the Classroom.

Since Greetings Island is free, there are advertisements. Some ads link to different card sites. This can be confusing to young users. It is recommended that before having your students or children create ecards, give them a quick tour of the site. Help them to differentiate between an advertisement link and a card selection.

Ecards and Digital Literacy

Ecards are one way to promote digital literacy. You may also want kids to send email, chat, or post on social media safely. TechnoInternet has many activities designed to teach safe online practices.

digital literacy activities for kids

TechnoInternet has a collection of digital literacy activities for kids.