Home > Articles > Scratch resources > 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.


© Sean McManus. All rights reserved.

Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!

Discover my latest books

Coding Compendium

Coding Compendium

A free 100-page ebook collecting my projects and tutorials for Raspberry Pi, micro:bit, Scratch and Python. Simply join my newsletter to download it.

Web Design in Easy Steps

Web Design IES

Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.

100 Top Tips: Microsoft Excel

100 Top Tips: Microsoft Excel

Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.

Scratch Programming in Easy Steps

Scratch Programming IES

This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.

Mission Python book

Mission Python

Code a space adventure game in this Python programming book published by No Starch Press.

Cool Scratch Projects in Easy Steps book

Cool Scratch Projects in Easy Steps

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

Walking astronaut from Mission Python book Top | Search | Help | Privacy | Access Keys | Contact me
Home | Newsletter | Blog | Copywriting Services | Books | Free book chapters | Articles | Music | Photos | Games | Shop | About