Scratch
Intermediate
60 mins
125 points
What you need:

Username Generator

In this lesson you will create a robot that first asks you some questions and then generates a username for you based on your answers!

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

2 - Add the Retro Robot sprite

We're going to use a robot sprite to ask you some questions. The answers to these will help make your username!

Once you've added the 'Retro Robot' sprite form the library, drag it to the middle of the stage area.


3 - Create a 'user name' variable

We will need to create a variable called 'user name' to store the text of our username as we build it.

When you create a variable, a small orange rectangle appears in the stage area that displays the current value of that variable. We don't need to this display so we're going to add the following code to hide it:

whenclickedhidevariableuser name

4 - Say the instructions

Our robot is going to give the instructions for using the username generator. Add the following code at the bottom of the 'when green flag clicked' blocks of code:

whenclickedsayI am the random username generator robot!for5secssayTo get a username, answer these questions...for5secs


5 - Get the first letter of their name

The start of the username is going to be the first letter of the person's name. We can get this by asking the person what their name is and then taking the first letter of their answer. Add the following code at the bottom of the when clicked blocks of code:

whenclickedsayI am the random username generator robot!for5secssayTo get a username, answer these questions...for5secs insert the new code below hereaskWhats your first name?andwaitsetuser nametoletter1ofanswer



Join our club 😃

To view the remaining 6 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of . Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more