Home life · Updated
How to Ask and Answer Questions in Scratch
Quick answer In Scratch, you ask a question with the Sensing block "ask [ ] and wait," and the player's typed answer is stored in the blue "answer" block, which you then use in comparisons or say blocks. The whole setup takes about 5 minutes and needs only the Scratch editor, which runs free in any browser.
How Do You Ask a Question in Scratch?
- Open the Scratch editor at scratch.mit.edu and either start a new project or open an existing one, then make sure a sprite is selected in the sprite panel at the bottom right.
- Drag out an event block. Pull “when green flag clicked” from the Events category (yellow blocks) into the code area so your question runs when the project starts.
- Attach the ask block. Go to the Sensing category (light blue blocks), drag “ask [What’s your name?] and wait” and snap it under the event block.
- Type your question into the white oval on the ask block, for example “What is 2 + 2?” — the player will see this text plus a typing box at the bottom of the stage.
- Use the answer. From the same Sensing category, drag the rounded “answer” block and drop it into a say block, a variable, or a comparison such as “answer = 4” inside an “if … then” block.
- Test it. Click the green flag, type a reply into the box at the bottom of the stage, press Enter, and watch the blocks after the ask block run with your reply stored in “answer.”
Why Your Question Block Might Seem Stuck
The ask block pauses the whole script until the player types something and presses Enter, so anything snapped below it simply waits. That is by design, and it is the reason the block is called “ask and wait.” If your sprite appears frozen, it is almost always one of these:
| Symptom | Cause | Fix |
|---|---|---|
| Nothing happens after the question | The answer is used in a separate script that started before the reply was typed | Put the blocks that use “answer” directly after the ask block, or use a broadcast after the answer arrives |
| Question box never appears | The ask block is under a hat block that never triggers, or the sprite is hidden | Check the script starts with “when green flag clicked” and add a “show” block |
| Answer seems empty | You are checking the answer too early, in a script that runs in parallel | Move the check into the same script chain, after the ask block |
| Wrong answer counted as right | Scratch compares text exactly, including capital letters and spaces | Compare with the exact text you expect, or convert both sides to the same case with a custom block |
How Do You Check Whether the Answer Is Right?
Put the “answer” block inside an Operators comparison block (green blocks) and wrap that in a Control “if … then / else” block. For a numbers question, use the green “= ” block with the rounded answer block on the left and the number 4 on the right. For a yes/no question, compare the answer to “yes” — and remember the comparison is case-sensitive, so “Yes” and “YES” will not match “yes” unless you also check those spellings.
A reliable pattern for quizzes: ask the question, use “if answer = (correct answer) then” to say “Correct!” and add one to a score variable, otherwise say “Try again” in the else arm. Chain several ask-and-check pairs in a row for a multi-question quiz, and the whole thing still runs top to bottom without any extra wiring.
Can You Ask Questions Without Stopping the Game?
The standard ask block always pauses the script that contains it, but other scripts keep running, so a background animation or timer in a separate script will continue. If you want the game to keep moving while collecting input, the usual workaround is to build your own on-screen buttons with sprites: a sprite shows the question as text, clickable option sprites each hold a value, and clicking an option sets a variable that your main script waits for with a “repeat until” loop. That is more work but suits fast-paced quizzes where pausing feels wrong.
Also note the ask box only accepts typed text — there is no built-in multiple-choice version of the ask block, so option sprites or typed letters (for example, ask the player to type A, B or C) are the two common routes.
Before You Start: What to Have Ready
- A Scratch account is not needed to build or test, only to save and share projects online.
- Any browser works; the editor needs no installation.
- Pick the sprite that should ask the question — the question box appears on the stage whoever the sprite is, but the say block text comes from the selected sprite.
- Have your questions and correct answers written out beforehand if you are building a quiz, since the case-sensitive comparison makes typos the most common bug.
How Long Does a Scratch Project Keep Working?
A saved Scratch project keeps working indefinitely — the answer block’s value simply resets each time the project restarts, so each new run asks and answers fresh. Projects saved to your account stay available across devices, and shared projects keep the same behaviour for anyone who opens them, so nothing about the ask-and-answer setup expires or needs renewing.
Related
- How to Prep for Interview Questions
- Chris Must List Trinidad? Answer & Context
- Football Rules the World? The Real Answer
Sources: Scratch Foundation. Menus and buttons can differ slightly by version. Spotted something out of date? Tell us.