# How to Make a Quiz Game in Scratch, Step by Step
Author: Arpita Jain
Author URL: https://www.codeyoung.com/blog/author/arpita-jain
Published: 2026-11-19
Category: Coding For Kids & Teens
Category URL: https://www.codeyoung.com/blog/category/coding-for-kids-and-teens
Meta Title: How to Make a Quiz Game in Scratch, Step by Step
Meta Description: Build a Scratch quiz game with ask and wait, lists, a score, a timer per question and random order, and fix the space bug that marks right answers wrong.
Tags: Coding For Kids, Scratch For Kids, Game Development For Kids, Scratch Programming, Coding Lessons
Tag URLs: Coding For Kids (https://www.codeyoung.com/blog/tag/coding-for-kids), Scratch For Kids (https://www.codeyoung.com/blog/tag/scratch-for-kids), Game Development For Kids (https://www.codeyoung.com/blog/tag/game-development-for-kids), Scratch Programming (https://www.codeyoung.com/blog/tag/scratch-programming), Coding Lessons (https://www.codeyoung.com/blog/tag/coding-lessons)
URL: https://www.codeyoung.com/blog/scratch-quiz-game

The first quiz game in Scratch most children build has a bug that marks correct answers wrong, and the usual suspect is the wrong one. Children and parents assume capital letters are the problem, and plenty of tutorials add extra blocks to handle them. Scratch's **`=` block already ignores capitals**; its source code converts both sides to lowercase before comparing. What it does not ignore is a **space**. Type "Paris " with a space at the end and Scratch says no.

This tutorial builds a complete Scratch quiz in seven steps: asking a question, checking the answer, keeping score, storing questions in lists so the quiz grows without new code, a timer on every question, random order with no repeats, and an end screen. Every block name is as it appears in Scratch 3. For a parent, the value is in what the project teaches underneath: lists, matching items by position, and two scripts cooperating, which is the first real program structure most children meet.

## Key Takeaways

- **`ask and wait` pauses its own script** until the player submits, and the reply lands in the `answer` block.
- The `=` block is **not case sensitive**, but it does not trim spaces from text. "Paris " and "Paris" do not match.
- Numbers are forgiving: **7, 07, 7.0 and " 7 " all match 7**, because Scratch compares them as numbers first.
- Two lists, **Questions and Answers, kept in the same order**, let a quiz grow from 5 questions to 50 without a single new block.
- A per-question timer needs a **second script**, and `stop other scripts in sprite` is what clears an unanswered question.

## Step 1: Ask one Scratch quiz question with ask and wait

Start with a single question so the moving parts are visible. Choose a sprite to be the quizmaster and give it this script:

1. `when green flag clicked` (Events).
2. `ask [What is the capital of France?] and wait` (Sensing).
3. `if <(answer) = [Paris]> then`, with `say [Correct] for (2) seconds` inside and `say [Not quite] for (2) seconds` in the `else` part. Use the `if then else` block from Control.

Click the green flag. The sprite shows the question in a speech bubble and an input box appears at the bottom of the stage. The player types and presses Enter or clicks the tick. Expected result: the sprite says Correct or Not quite.

Three behaviours are worth knowing now, because they shape everything later:

- **The script really stops.** Nothing below `ask and wait` runs until the player submits. That is why a timer cannot live in the same script.
- **Where the question appears depends on who asks.** A visible sprite asks in a speech bubble. If the stage asks, or the sprite is hidden, the question text appears above the input box instead, which reads better for long questions.
- **`answer` holds only the most recent reply**, and Scratch clears it to empty when the green flag is clicked. There is one `answer` for the whole project, shared by every sprite.

## Step 2: How Scratch checks a quiz answer, and the space bug

Scratch's `=` block makes one decision before it compares anything: can both sides be read as numbers? If yes, it compares them as numbers. If either side is not a number, it compares them as text, after converting both to lowercase. That one rule, visible in the `compare` function of Scratch's own code, explains every surprise a quiz produces.

![Six answer tiles showing how the Scratch equals block judges typed quiz answers: PARIS and paris match Paris, Paris with a trailing space does not, and 07, 7.0 and seven compared against 7 give match, match and no match](https://prod.superblogcdn.com/site_cuid_clvc4016q001j13bhaleswmt1/images/scratch-equals-block-answer-matching-rules-1795439538689-compressed.png)Capitals never matter. A trailing space matters for words but not for numbers, because a number with spaces around it still reads as a number.

What that means in practice:

Player typesStored answerResultWhyPARISParisMatchText is compared in lowercaseParis (space after)ParisNo matchText is not trimmed, so the space counts077MatchBoth read as the number 77.07MatchBoth read as the number 77 (space before)7MatchSpaces around a number are ignored when it is read as a numberseven7No match"seven" is not a number, so it is compared as text(nothing)0No matchScratch treats an empty answer as text, not as zero

So a maths quiz is forgiving and a word quiz is not. One stray tap of the space bar before Enter is all it takes, and nothing on screen shows the player that it happened.

### The fix: a small tidy block that removes spaces

Scratch 3 has no trim block, so make one. In My Blocks, click **Make a Block**, name it `tidy`, add one input called `text`, and tick **Run without screen refresh** so it finishes instantly. Make two variables, `tidied` and `i`. Then build:

1. `set [tidied] to []`, leaving the slot empty.
2. `set [i] to (0)`.
3. `repeat (length of (text))`, using `length of` from Operators.
4. Inside the repeat: `change [i] by (1)`, then `if <not <(join (letter (i) of (text)) (join [5] (letter (i) of (text)))) = [5]>> then`. Inside the if: `set [tidied] to (join (tidied) (letter (i) of (text)))`.

That odd-looking test avoids typing a space into a block slot, which is hard to see and easy to get wrong. It wraps the letter around a 5: a space becomes " 5 ", which Scratch reads as the number 5 because spaces around a number are ignored, the same rule as in the table above. Any other character breaks it: "a5a" is not a number, and "050" is 50, not 5. So the test is true only for blank characters such as a space, and only visible letters get copied into `tidied`. Test the block once before relying on it: run `tidy [ Paris ]` with the `tidied` checkbox ticked and the stage should show Paris.

Run `tidy (answer)`, store `tidied` in a variable called `given`, then run `tidy` on the stored answer and compare `given` with `tidied`. Spaces vanish from both sides, so "Paris ", " Paris" and "Paris" all match. The trade-off: "New York" and "NewYork" now match too, which for a children's quiz is a feature.

Resist the shortcut of `<(answer) contains [Paris]?>`. It is also case-insensitive and does ignore stray spaces, but it accepts "not Paris" as correct, and for a number quiz it accepts 12 as an answer to "What is 1 + 1?" because 12 contains 2.

## Step 3: Keep score with a variable

Make a variable called `score`, set to **For all sprites**, so the end screen can read it. Put `set [score] to (0)` straight under the green flag hat, before any question, and `change [score] by (1)` inside the correct branch. Without the reset, the score carries over from the last run. We cover variable scope and the four score blocks properly in [building a score counter in Scratch](https://www.codeyoung.com/blog/scratch-score-counter), so here it is one variable and two blocks.

A quiz is often the first project where a child has to keep two scripts and three lists in their head at once. A free trial class with a Codeyoung teacher shows you exactly where your child is with that, and what they are ready for next, before you commit to anything.

[Book a Free Trial →](https://book-a-demo.codeyoung.com?utm_source=blog&utm_medium=codeyoung&utm_campaign=scratch-quiz-game)

## Step 4: Store questions and answers in two lists

One `ask` block per question works for five questions and collapses at twenty, because every change means editing every copy. Lists fix that. In Variables, click **Make a List** twice to create `Questions` and `Answers`, both For all sprites.

The rule that makes the whole design work: **item 3 of Answers is the answer to item 3 of Questions.** The two lists are matched by position, never by searching. Fill them in the same order using the **+** button at the bottom of each list on the stage.

![Two Scratch list monitors side by side labelled Questions and Answers, items 1 to 5, with row 3 highlighted across both lists to show 6 times 7 paired with 42 by item number](https://prod.superblogcdn.com/site_cuid_clvc4016q001j13bhaleswmt1/images/scratch-parallel-lists-questions-answers-by-position-1795439544548-compressed.png)The lists are linked only by item number. Delete one row from Questions without deleting the matching row from Answers and every later question gets the wrong answer.

Now the question script uses a variable `Q` for the question number:

- `ask (item (Q) of [Questions]) and wait`
- compare the answer with `item (Q) of [Answers]`

To add a sixth question, add one item to each list. No new blocks. For a long quiz, typing into the stage gets slow: right-click a list on the stage, choose **import**, and pick a .txt or .csv file with one item per line. **export** on the same menu saves the list back out, which is a sensible backup before a big edit. A list can grow to 200,000 items before Scratch 3 refuses to add more, so size is never the constraint. If your child wants better questions than "capital of France", our [coding quiz questions for kids](https://www.codeyoung.com/blog/coding-quiz-questions-for-kids) has 50 sorted by age, and coding questions make a fitting quiz for a coding project.

## Step 5: Shuffle the questions without repeats

The obvious approach, `set [Q] to (pick random (1) to (length of [Questions]))`, repeats questions. With five questions, there is a one-in-five chance the second question is the same as the first. The fix is a third list that acts like a deck of cards.

1. Make a list called `Order` and variables `n` and `pick`.
2. Under the green flag: `delete all of [Order]`, `set [n] to (0)`, then `repeat (length of [Questions])` with `change [n] by (1)` and `add (n) to [Order]` inside. Order now holds 1, 2, 3, 4, 5.
3. For each round: `set [pick] to (pick random (1) to (length of [Order]))`, then `set [Q] to (item (pick) of [Order])`, then `delete (pick) of [Order]`.

Each round removes the number it used, so Order shrinks by one every question and no number can come up twice. When `length of [Order]` is 0, every question has been asked.

![Five snapshots of a Scratch list called Order shrinking from five items to empty, one number removed each round: 4, then 1, then 5, then 2, then 3, ending with Quiz over](https://prod.superblogcdn.com/site_cuid_clvc4016q001j13bhaleswmt1/images/scratch-order-list-draw-without-repeats-1795439550637-compressed.png)Picking a position, using the number stored there, then deleting that position is the whole trick. The list doing the remembering is why no extra checks are needed.

One detail matters: `pick random` only returns whole numbers when both inputs are whole numbers. Type `1.0` in the first slot and it returns decimals like 2.71, and `item (2.71) of` a list is not what anyone wants. Keep it `1`.

## Step 6: Add a timer to every question

Because `ask and wait` freezes its script, the clock has to run in a second script that the question script starts. Broadcasts do that. Make a variable `answered`, a variable `time left`, and two messages, `next question` and `start clock`. The full quizmaster sprite then has three scripts.

**Script A, setup:** `when green flag clicked`, `set [score] to (0)`, fill Order as in Step 5, `broadcast [next question]`.

**Script B, the question:**

1. `when I receive [next question]`
2. `if <(length of [Order]) = (0)> then`: `stop [other scripts in sprite]`, `broadcast [quiz over]`, `stop [this script]`.
3. Pick `Q` from Order as in Step 5.
4. `set [answered] to (0)`, then `broadcast [start clock]`.
5. `ask (item (Q) of [Questions]) and wait`, then `set [answered] to (1)`.
6. Tidy and compare as in Step 2. Correct: `change [score] by (1)` and `say [Correct] for (1) seconds`. Wrong: `say (join [It was ] (item (Q) of [Answers])) for (2) seconds`.
7. `broadcast [next question]`.

**Script C, the clock:**

1. `when I receive [start clock]`, then `reset timer`.
2. `repeat until <<(timer) > (10)> or <(answered) = (1)>>`, with `set [time left] to ([ceiling] of ((10) - (timer)))` inside, taking `ceiling` from the dropdown on the `abs of` block.
3. `if <(answered) = (0)> then`: `stop [other scripts in sprite]`, `say [Time is up] for (1) seconds`, `broadcast [next question]`.

The line doing the real work is `stop [other scripts in sprite]`. It ends Script B mid-question, and when a sprite's scripts are stopped, Scratch also removes that sprite's unanswered question and its input box. Without it, the box stays on screen after time runs out. The Scratch Wiki suggests putting the question in a separate sprite for this; it works in the same sprite too, provided the quizmaster holds only these three scripts, since anything else in it would be stopped as well.

Two things that look like bugs and are not. When Script B broadcasts `next question` to itself, Scratch restarts the script from the top, which is how the quiz loops without a `forever`. And the `timer` block is shared by the whole project, so if another sprite also uses `reset timer`, the two will fight; for a countdown elsewhere in the game, the counting-variable method in [our Scratch timer tutorial](https://www.codeyoung.com/blog/how-to-make-a-timer-in-scratch-step-by-step-timer-tutorial-for-students) avoids the clash.

Expected result: tick `time left` to show it on the stage, click the green flag, and watch it count 10 down to 1. Answer in time and the next question appears at once. Wait, and the box disappears, the sprite says Time is up, and a new question follows.

## Step 7: Build the Scratch quiz end screen

The end screen listens for `quiz over`, so put it on the stage or on a second sprite. Draw a results backdrop, then:

1. `when I receive [quiz over]`
2. `switch backdrop to [results]`
3. `say (join [You scored ] (join (score) (join [ out of ] (length of [Questions])))) for (3) seconds`, or for a percentage, `round (((score) / (length of [Questions])) * (100))`.
4. `stop [all]`.

Use `length of [Questions]` for the total, not `length of [Order]`, because Order is empty by now. Clicking the green flag again resets the score, refills Order and starts a new shuffle. If the score should survive a page reload as a best-ever result, that needs a cloud variable, which [saving a high score in Scratch](https://www.codeyoung.com/blog/scratch-save-high-score) walks through, including why the cloud option is sometimes greyed out.

## Where a quiz project goes next

The finished quiz game in Scratch is four scripts, one custom block and three lists, and every extension reuses an idea already built. A third list, `Options`, turns it into multiple choice. A `Topic` list plus a filter makes themed rounds. Sending `quiz over` to a second sprite that plays a sound is the same broadcast pattern explained in [our guide to Scratch broadcast blocks](https://www.codeyoung.com/blog/scratch-broadcast-blocks).

The honest caveat for parents: Steps 1 to 4 suit a child who has finished a couple of guided projects. Steps 5 and 6 are a genuine step up, because the child has to reason about two scripts running at once and a list that changes while it is being used. A good test of whether the clock is understood rather than copied: remove the `answered` check, answer a question at the ninth second, and watch the quiz announce Time is up over a correct answer. Working out why takes about five minutes and teaches more than the build did.

Codeyoung runs 1:1 live online classes for children aged 6 to 17, with a teacher who adapts the pace to your child rather than a fixed syllabus. In our [Scratch classes](https://www.codeyoung.com/coding/scratch-coding-classes-for-kids?utm_source=blog&utm_medium=codeyoung&utm_campaign=scratch-quiz-game), projects like this quiz are built with a teacher watching the screen, so a stray space gets explained rather than guessed at. The first class is free, so you can see how they respond before deciding.

[Book a Free Trial](https://book-a-demo.codeyoung.com?utm_source=blog&utm_medium=codeyoung&utm_campaign=scratch-quiz-game)

Sources checked 23 November 2026: the Scratch Wiki pages for [Ask () and Wait](https://en.scratch-wiki.info/wiki/Ask_()_and_Wait_(block)), Answer, [() = ()](https://en.scratch-wiki.info/wiki/()_%3D_()_(block)), Pick Random () to (), Item () of (), Stop (), When I Receive () and List; and the scratch-vm source on GitHub ( [util/cast.js](https://github.com/scratchfoundation/scratch-editor/blob/develop/packages/scratch-vm/src/util/cast.js) for how `=` compares, blocks/scratch3\_sensing.js for ask, answer and question clearing, blocks/scratch3\_data.js for the 200,000 item list limit, blocks/scratch3\_operators.js for pick random and contains). Scratch updates occasionally, so check block behaviour on scratch.mit.edu if something does not match.
## FAQs
Q: How do you make a quiz game in Scratch?
A: Put the questions in one list and the answers in a second list in the same order. A script picks a question number, uses ask and wait to show the question, then compares the answer block with the matching item of the answers list and changes a score variable by 1 when they match.

Q: Is the Scratch answer check case sensitive?
A: No. The equals block in Scratch 3 compares text without case sensitivity, so PARIS, paris and Paris all match. The Scratch source code converts both sides to lowercase before comparing. You do not need to build a lowercase converter for a quiz, which many tutorials still suggest.

Q: Why does Scratch mark a correct answer wrong?
A: Almost always a stray space. Scratch does not trim the answer, so Paris with a space after it is a different piece of text from Paris and the equals block reports false. Numbers behave differently: a space around 7, or 7.0, still matches 7, because both sides are compared as numbers first.

Q: How do I add a timer to each question in a Scratch quiz?
A: Run the clock in a second script, because ask and wait pauses the script that asked. That script resets the timer, waits until the timer passes your limit or the question is answered, and if time ran out uses stop other scripts in sprite, which also removes the unanswered question box.

Q: How do I make Scratch quiz questions appear in random order without repeats?
A: Fill a third list with the numbers 1 up to the number of questions. Each round, pick a random position in that list, use the number stored there as the question, then delete that position. The list shrinks by one each round, so no question can come up twice, and the quiz ends when it is empty.

Q: How many questions can a Scratch quiz hold?
A: Far more than any quiz needs. Scratch 3 stops adding items to a list once it holds 200,000. You can type questions in directly, or right-click the list on the stage and import a .txt or .csv file, which is much faster for a quiz of thirty or more questions.




---
This blog is powered by Superblog. Visit https://superblog.ai to know more.
---

