It's Sean!

UK freelance journalist, author
and writer Sean McManus

Printed from www.sean.co.uk. © Sean McManus.

NEW: Sign up for my newsletter!

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.

Books by Sean McManus

Scratch Programming in Easy Steps

Scratch Programming in Easy Steps

Raspberry Pi For Dummies

Raspberry Pi For Dummies

Learn to program with the Scratch programming language, widely used in schools and colleges.

Set up your Pi, master Linux, learn Scratch and Python, and create your own electronics projects.

Coder Academy

Coder Academy

Cool Scratch Projects in Easy Steps

Cool Scratch Projects in Easy Steps

Learn to make games and other programs in Scratch 2.0, and make a web page in HTML, with this highly interactive book for 7-10 year olds.

Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!

More books

Recommended articles

Stylised coloured photo of a synth

Discover my music and home recording articles

Interested in starting home recording? Follow me as I start recording, using instruments such as the Novation MiniNova and Korg Kaossilator, and share my synth and sample-based music online.

Scratch cat and rainbow circle

10-block demos for Scratch programming

Lots of people of all ages are learning to program with Scratch. Discover some useful tricks and techniques in my 10-block Scratch demos, including special effects you can drop into your games.

Paper Raspberry Pi case

Download free book chapters and more!

Download a free case for your Raspberry Pi, and free chapters from my books about the Raspberry Pi, Scratch, web design and more!

©Sean McManus. www.sean.co.uk.