It's Sean!

UK freelance journalist, author
and copywriter Sean McManus

Printed from © Sean McManus.
Home > Books > Scratch Programming in Easy Steps > 10 block demos > How to add a password in Scratch

How to add a password to your Scratch game

Sean McManus, author of Scratch Programming in Easy Steps and Cool Scratch Projects in Easy Steps, shows you how to password protect your programs in Scratch

To help my Code Club group to understand how the repeat until loop works, I created a simple password program. They loved it, and had fun coming up with their own passwords, and coming up with variants such as asking for someone's name and only letting a few selected friends in.

This program also shows how to ask the player to type in information, how to use the answer block handle that information, and how to use broadcasts to start a program.

This isn't secure: don't use it to try to protect sensitive information. It's for fun only.

Feel free to use this example in your classroom, Code Club, or your own games and Scratch programs!

How to use the password routine for Scratch

  1. Add this script to your gatekeeper sprite who will ask for the password:

    When this sprite clicked / Repeat until answer = zippy / ask what's the password and wait / end of repeat / say That's right! / Broadcast start the program

  2. Change the word 'zippy' to your chosen password or phrase
  3. When the program starts, set all your other sprites to hide:

    When green flag clicked / hide

  4. Add a script like this to all those other sprites too:

    When I receive start game / show

  5. Use that last script as the start of that sprite's actions. For example, if it enters a movement loop, tack it on the end after that Show block.

Demo card for sharing

Here's a card that summarises this password script for easy sharing. Feel free to share the image below on Twitter, Facebook or your other social networks

Card demonstrating broadcasts using the code explained above

Find out more...

Find more 10 block Scratch demos here. For more information on my Scratch books and more bonus content, visit the Scratch Programming in Easy Steps and Cool Scratch Projects in Easy Steps homepages.