In the previous activity, we used variables to track a sprite's position automatically. In this activity, we will take it a step further — we will ask the user for input and save their response in a variable. This makes our programs interactive and personalized!
Setting Up
- Open PictoBlox and create a New File.
- Select Block Coding as the coding environment.
- Choose any sprite you like — we will use Tobi for this activity.
Creating the Variables
- Go to the Variables palette and click Make a Variable.
- Create a variable called Name.
- Create another variable called Age.
- Make sure both variables are set to For all sprites.
The Ask Block
The 'Ask () and wait' block is found in the Sensing palette. When this block runs, a text input box appears at the bottom of the Stage, and the program pauses until the user types an answer and presses Enter.
Key Blocks for This Activity
Building the Script
Now let's build the script that asks the user for their name and age, saves both into variables, and has Tobi greet them. You will find the blocks in the mentioned palettes:
- When flag clicked — Events
- Ask (What is your name?) and wait — Sensing
- Set (Name) to (answer) — Variables
- Ask (How old are you?) and wait — Sensing
- Set (Age) to (answer) — Variables
- Say (join (Hello ) (join (Name) (! Great to meet you!))) for (3) seconds — Looks & Operators

Running the Script
- Click the green flag to start the program.
- A question box will appear at the bottom of the Stage — type your name and press Enter.
- The next question will appear — type your age and press Enter.
- Watch Tobi greet you by name using the values stored in the variables!

Challenge
Try extending the script to ask the user one more question — such as their favorite color or their favorite animal — and have Tobi respond with a fun message using their answer!

.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)