How to add a password to your Scratch game
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
- Add this script to your gatekeeper sprite who will ask for the password:
- Change the word 'zippy' to your chosen password or phrase
- When the program starts, set all your other sprites to hide:
- Add a script like this to all those other sprites too:
- 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