Make a Whack-a-Mole Game in Scratch for Kids
![]() |
| KidsKod original illustration. |
Ready for a fast, funny game you can build in one afternoon? In this KidsKod project you will make a Whack-a-Mole game in Scratch: cheeky moles pop out of holes, and you click them as fast as you can before the timer runs out. If you enjoyed our Catch the Stars game in Scratch, this one uses some of the same ideas, plus a countdown timer and random hiding spots.
What you need
- A computer or tablet with a web browser
- Free Scratch at scratch.mit.edu (an account lets you save your game, but you can also try it without one)
- About 45 minutes and a grown-up nearby to cheer you on
What you will learn
- How to use variables to keep score and count down time
- How to move a sprite to random positions
- How to use show and hide to make things pop up
- How to react to clicks with
when this sprite clicked - How to broadcast a message to end the game
Step 1: Set up the stage
- Open Scratch and click Create.
- Right-click the cat sprite and choose delete.
- Click the Choose a Backdrop button and pick a grassy one, or paint your own green field.
- Use the paint tool to draw 3 to 6 dark ovals as mole holes. Remember roughly where they are!
Step 2: Add your mole
- Click Choose a Sprite. Scratch has no mole, so pick a cute animal (the Hedgehog or a Mouse works well) or paint your own mole.
- Rename the sprite to
Mole. - Make it small enough to fit in a hole. Set its size to about 50.
Step 3: Make two variables
- Go to the orange Variables blocks and click Make a Variable.
- Create
Score(for all sprites). - Create
Time(for all sprites). - Keep both check boxes ticked so they show on the stage.
Step 4: Make the mole pop up in random holes
Click the Mole sprite and build this script:
when green flag clickedhideforevergo to x: (pick random -180 to 180) y: (pick random -120 to 80)showwait (pick random 0.5 to 1.2) secondshidewait (pick random 0.3 to 1) seconds
Tip: Want the mole to appear only in your holes? Instead of random x and y, make a list called HolesX and HolesY with the position of each hole, then use pick random 1 to (length of HolesX) to choose a hole number.
Step 5: Score points when you whack it
- Add a new script to the Mole:
when this sprite clicked. - Add
change Score by 1. - Add
start sound (Pop)from the Sound blocks for a fun bonk. - Add
hideso the mole ducks away after it is hit.
Step 6: Add a 30-second countdown
Click the Stage (bottom right) and build:
when green flag clickedset Score to 0set Time to 30repeat until (Time = 0)wait 1 secondschange Time by -1
broadcast (Game Over)
Step 7: End the game
- Back on the Mole sprite, add
when I receive (Game Over). - Add
hide, thenstop (other scripts in sprite)so no more moles pop up. - Add a new sprite with the words Game Over! Make it
hidewhen the green flag is clicked andshowwhen it receivesGame Over.
Step 8: Test and tweak
- Click the green flag and play. Can you beat 15 points?
- Too hard? Make the wait times bigger. Too easy? Make them smaller.
- Ask a friend or family member to play and see who gets the high score.
Wrap-up and challenge
Great job! You built a real game with variables, random numbers, a timer and broadcasts, the same ideas game designers use every day. Now try a level-up challenge:
- Golden mole: duplicate the Mole, color it gold, and make it worth 5 points but appear rarely.
- Don't whack the bunny: add a sprite that takes away 2 points if you click it.
- Speed up: make the moles pop faster when
Timeis less than 10.
Share your game on Scratch and keep coding with KidsKod!
