Code Your Customers on Scratch
Green highlight

Create an interactive Scratch project that simulates customers visiting a shop, programming behaviors, responses, and simple transactions to practice coding and logic.

Orange shooting star
Download Guide
Collect Badge
Background blob
Challenge Image
Skill Badge
Table of contents

Step-by-step guide to Code Your Customers on Scratch

What you need
Coloring materials, paper, pencil, scratch account, sticky notes

Step 1

Open scratch.mit.edu and click Create to start a new project.

Step 2

Click the Stage and choose or paint a shop backdrop with a counter and a door.

Step 3

Add a shopkeeper sprite and place it behind the counter.

Step 4

Add at least two customer sprites and give each a different costume then place them offstage near the door.

Step 5

For each customer sprite create a variable named budget for this sprite only and add a block when green flag clicked set budget to pick random 5 to 20.

Step 6

Create at least two item sprites for sale and for each item create a variable named price for this sprite only and set price to a number when green flag clicked.

Step 7

Create a global variable named currentPrice and program each item so that when the item is clicked it sets currentPrice to its price and broadcasts itemSelected.

Step 8

For each customer sprite add blocks so that when the green flag is clicked the customer waits pick random 1 to 4 seconds then shows and glides 1 second to the counter.

Step 9

For each customer sprite add a when I receive itemSelected block that checks if the customer is touching the counter and if so broadcasts askPrice.

Step 10

In the shopkeeper sprite add a when I receive askPrice block and make the shopkeeper say join "Price is $" currentPrice for 2 seconds.

Step 11

In the customer sprite add a when I receive askPrice block that waits 1 second then if budget >= currentPrice changes budget by -currentPrice broadcasts buy and says "Thanks" else says "I can't afford it" and glides 1 second out the door.

Step 12

In the shopkeeper sprite add a when I receive buy block that changes a shopMoney variable by currentPrice plays a sound and makes the bought item hide or show a sold look.

Step 13

Click the green flag to test the project and then tweak budgets prices and timings until customers enter ask and buy as you want.

Step 14

Share your finished interactive shop project on DIY.org.

Final steps

You're almost there! Complete all the steps, bring your creation to life, post it, and conquer the challenge!

Complete & Share
Challenge badge placeholder
Challenge badge

Help!?

What can we do if we can't open scratch.mit.edu or have no internet?

Use the Scratch Desktop offline editor and follow the same steps—create the store backdrop, sprites, per-sprite variables (budget, price), the global currentPrice and broadcasts—then save the .sb3 file to upload or share later on DIY.org.

Why do customers sometimes not ask for the price or never trigger askPrice?

If the when I receive itemSelected check for 'touching the counter' fails, make the counter a separate sprite (not just part of the backdrop) or adjust your customer's glide coordinates so they overlap the counter sprite before broadcasting askPrice.

How can I adapt this activity for younger or older kids?

For younger kids pre-make the shopkeeper and item sprites, set simple fixed budgets and prices and remove some broadcasts, while older kids can add lists for inventory, random discounts, expanded shopMoney tracking and more complex broadcasts and conditionals.

What are easy ways to extend or personalize the shop project?

Add features like a receipt sprite, customer satisfaction variable, seasonal price changes tied to currentPrice, coin animations that update shopMoney when you broadcast buy, and use item costumes or hide/show to display a sold look.

Watch videos on how to Code Your Customers on Scratch

0:00/0:00

Here at SafeTube, we're on a mission to create a safer and more delightful internet. 😊

Get Started with Scratch Guide: 5 Tips & Tricks for Beginners 🎉

4 Videos

Facts about block-based programming and game design for kids

🤖 Agent-based models let you simulate many independent customers, each following simple rules to create surprising group behavior.

🧩 Scratch projects are built from colorful drag-and-drop code blocks, making programming logic easy to explore without typing.

🐱 Scratch's mascot is a friendly cat — Scratch was created at MIT and has a huge online community sharing projects.

🎯 Using randomness (like the 'pick random' block) makes customer visits and choices unpredictable and your shop more fun to play.

💳 You can model shop transactions in Scratch using variables and lists to track money, inventory, and receipts.

How do I create a "Code Your Customers" interactive project on Scratch?

Start by planning your shop: choose sprites for customers, cashier, items, and backgrounds. In Scratch, add sprites and costumes, create variables (money, inventory) and lists (orders). Use broadcasts for events (customer_arrives) and if-else blocks to handle choices and payments. Randomize customer requests with pick random and use wait blocks for pacing. Program transactions by checking inventory and changing money variables. Test often and iterate—add sounds, timers, and difficulty levels as

What materials do I need to build a Scratch shop simulation?

You need a computer or tablet with internet access and a browser, a free Scratch account (optional but useful), and a mouse or touchscreen. Also have a notebook and pencil for planning sprites, menus, and variables. Optional materials: headphones for sound, printable templates for item cards, and a parent or teacher for guidance. For offline practice, download the Scratch Desktop editor. No special hardware or coding experience required—just curiosity and time.

What ages is the "Code Your Customers" activity suitable for?

This activity suits children ages 8 to 14, since Scratch’s block coding matches that age group's reading and logic skills. Younger kids (5 to 7) can try a simplified version with adult help or use ScratchJr. Older kids and teens can expand features with lists, variables, and broadcasts. Adjust complexity: start with simple customer arrivals and add payment logic, special requests, or timers as learners grow.

What are the benefits of coding customer simulations in Scratch?

Coding customer simulations teaches sequencing, conditionals, variables, event-driven programming, and debugging skills in a playful context. Kids practice math (prices, totals), logic (if-else choices), creativity (sprite design, dialogue), and empathy by modeling customer behavior. It also builds problem-solving, persistence, and collaboration if working in teams. Encourage reflection: ask children to explain designs and improve interfaces to reinforce learning and communication skills.
DIY Yeti Character
Join Frame
Flying Text Box

One subscription, many ways to play and learn.

Try for free

Only $6.99 after trial. No credit card required

Code Your Customers on Scratch. Activities for Kids.