How to Keep Score in Scratch, Game Design

Keep score in Scratch

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.

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.
new variable
Create a score variable.
  1. Select the score variable to display it. score variable

Build the Script

  1. 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.
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

  1. 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?
  1. 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

  1. Play the game again. Does the score start at zero? NO, it doesn’t.
  2. Select the player sprite.
  3. 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.
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?

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

Christa Love

Christa Love, Curriculum Developer & Teacher ~ I am passionate about blending technology into curriculum. Whether it is programming, video production, graphic design, or digital citizenship, I am interested in how apps and tools can be used to enhance learning. Throughout the years I have designed many TechnoKids technology projects. My favorite part of curriculum development is field-testing the ideas to determine the activities that work best in real classrooms. I write about what I have learned that can save teachers time in their own curriculum planning.

You may also like...