Game tutorial · Quiz

How to make a quiz game in Scratch (step by step, with an AI helper)

A quiz game is a great project for kids who like words more than action: a host asks questions, the player types answers and the game keeps score. Built the smart way – with lists instead of copying blocks for each question – it also teaches one of the most useful ideas in programming: keeping data separate from code. This guide builds a quiz in Scratch 3 step by step, and shows where Bee, the AI buddy in Enimist's Maker Studio, can help.

Make a quiz host

Pick or draw a friendly host sprite and a backdrop – a game-show stage, a classroom, a space station. The host does all the talking, so all the code in this guide goes on the host.

Bee drawing a costume and a backdrop from a description (Vietnamese interface shown)
Bee drawing a costume and a backdrop from a description (Vietnamese interface shown)

Tip: The “Draw for me” chip in the Maker Studio's Bee panel can draw the host (“a cheerful robot with a microphone”) and a game-show backdrop.

One question with ask and answer

Start with a single question to see how it works. “ask and wait” shows a text box and pauses until the player presses Enter; whatever they typed is kept in the “answer” block.

Compare answer with the right answer using “=”. Scratch compares text without caring about capital letters, so “Paris” and “paris” both count – handy for young players.

Blocks
when green flag clicked
ask (What is the capital of France?) and wait
if <(answer) = (Paris)> then
  say (Correct!) for (1) seconds
else
  say (Not quite – it's Paris.) for (2) seconds

Put the questions in lists

Copying that block group for every question gets messy fast. Instead, make two lists (Variables → Make a List): “questions” and “answers”. Item 1 of answers is the answer to item 1 of questions, and so on.

Fill them at the start of the game with “add … to …”, or type items directly into the lists on the stage. Adding a new question now means adding two items – no new code.

Blocks
delete all of [questions]
delete all of [answers]
add (What is 7 × 8?) to [questions]
add (56) to [answers]
add (How many legs does a spider have?) to [questions]
add (8) to [answers]

Loop through every question

Use a variable “n” as the question number. Start at 1, repeat once for each question (length of questions), ask item n, check the answer against item n of answers, then change n by 1.

Add 1 to “score” for each correct answer. This loop works for 3 questions or 300 without changing a single block.

Common mistakes: forgetting to set n back to 1 at the start (the second game then asks nothing), putting “change n by 1” inside the if so it only moves on after a correct answer, and lists of different lengths – if “answers” has one item fewer than “questions”, the last question can never be answered correctly. Show both lists on the stage while testing so you can see them line up.

Blocks
set [n] to (1)
set [score] to (0)
repeat (length of [questions])
  ask (item (n) of [questions]) and wait
  if <(answer) = (item (n) of [answers])> then
    say (Correct!) for (1) seconds
    change [score] by (1)
  else
    say (join (The answer is ) (item (n) of [answers])) for (2) seconds
  change [n] by (1)

Show the result

After the loop, tell the player how they did with join: “You got 4 out of 5!”. Pick a message by score – a big cheer for a perfect score, encouragement otherwise.

Add a sound for right and wrong answers to make it feel like a real game show. Bee's “Make a sound” chip can make “a happy ding” and “a soft buzz”.

Blocks
say (join (join (You got ) (score)) (join ( out of ) (length of [questions]))) for (3) seconds
Bee making a sound effect, with Stop and Open the Sounds tab buttons (Vietnamese interface shown)
Bee making a sound effect, with Stop and Open the Sounds tab buttons (Vietnamese interface shown)

Stuck? How the AI buddy can help

If every answer is marked wrong, the lists are often out of order or have an extra space. Ask Bee in the Maker Studio: “My quiz says every answer is wrong” – Bee can see your blocks and lists and will help you find it.

You can also ask Bee for question ideas on a topic you are learning, then type them into your lists yourself. Want Bee to build it? Type what you want – “add a 10-second timer for each question” – and Bee reads your project, prepares the change as a draft card (“Bee will: add 1 script(s)”) and waits. Tap Apply to put it in your project, or Discard; after applying, Undo puts everything back. Then tap “Done” to see how much of the game you made yourself.

Bee answering a question with a picture of the blocks (Vietnamese interface shown)
Bee answering a question with a picture of the blocks (Vietnamese interface shown)

Scratch is a project of the Scratch Foundation, in collaboration with the Lifelong Kindergarten Group at the MIT Media Lab. Enimist Studio is not affiliated with Scratch or the Scratch Foundation.

Ready to make a first game?

Open the Maker Studio on a computer – Bee will be there from the very first block.

More guides