Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Secret Password


This video lets you protect your story with a secret password.

Anyone can look at your code to know this password, so it isn’t very secure.

To ask for the secret password, you will use a block that allows for user input called the “ask” block.

From the “sensing” menu, place an “ask” block in the sprites area.

In the white box, type the question you want the sprite to ask.

For this example, the question is “what is the secret password?”

Click on the block.

The sprite asks the question, then a box appears at the bottom of the stage.

This box is where the person watching your story will type in what they think the password is.

What they type in this box will be saved in a variable called “answer.”

To see what is stored in that variable, go to the “sensing” menu, and click on the checkbox next to “answer.”

Type an “answer” in the box at the bottom of the stage.

You’ll notice what you type shows up in the blue box at the top left of the stage.

Place the “ask” block under the “when flag clicked” block.

Now, tell the sprite to repeat asking the password until the user gets it right.

From the “control” menu place a “repeat until” block after the “ask” block.

This may put the “repeat until” block around your story - take the story out and place it under the “repeat until block.

Next, program the condition that will stop the repeating - when the answer is equal to the secret password.

From the “operators” menu, place the “equals” block inside the “repeat until” block.

From the “sensing” menu, place “answer” on one side of the equals block.

Type the secret password on the other side of the “equals” block.

Next, place actions that should repeat until the password is entered inside the repeat loop.

From the “looks” menu, place a “say” block inside the “repeat until” loop.

Make the sprite say “Nope!”

Then ask the question again.

From the “sensing” menu, place an “ask” block after the “say” block.

Test the code by clicking the green flag.

The sprite asks for the password.

First, get it wrong.

The sprite says “nope” then asks again.

Get it wrong again.

The sprite says “nope” and asks again.

This time, get it right.

The sprite stops asking the question and instead starts the story.


Click the stop sign to stop the story.

Try getting the answer right the first time this time.

The sprite doesn’t ask for the password again!


But wait - the friend shows up 8 seconds after the green flag is clicked, regardless of the secret password.

That’s because the code tells the friend to show up 8 seconds after the green flag is clicked.

The wait shouldn’t even start until the correct secret password has been entered.

The “my” sprite knows when this happened, It can let the “friend” sprite know using the “broadcast” block.

From the “events” menu place a “broadcast” block after the “repeat until” loop.

From the dropdown, select “new message” and give it a name that makes sense, like “start story.”

Next, click on the friend sprite.

Disconnect the “wait” block from the “hide block” From the “Events” menu, place a “when I receive” block on top of the “wait” block.

Now it’s your turn: Ask for the secret password using an “ask” block.

Keep asking until the password is correct using “repeat until” “answer” “equals” “ask” and “say” blocks.

Let the friend sprite know the story has started with a “broadcast” block.

and finally, detach the entire block stack after the “hide block” and connect it to a “when I receive” block on the friend sprite.

Choose an Add-On
Add a Soundtrack
Add music to run in the background of your project.
Changing Backdrops and Costumes
Add different scenes to your story.
Changing Looks with Code
Learn what the "looks" blocks can do.
Move Around the Stage
Discover ways to make sprites move.
Animate sprites by creating new costumes.
Secret Password
Make a password to protect your story.
arrow_backward Back
Next arrow_forward
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!