🧩 Hat Blocks
Rounded tops - These start your scripts! Like “when green flag clicked” or “when space key pressed.”
In Scratch, blocks are like LEGO pieces for programming, and scripts are the towers you build by connecting them together. Each block has a special purpose, and when you combine them thoughtfully, amazing things happen!
Blocks are the building pieces of Scratch programming. Each block:
Understanding block shapes is crucial for creating working scripts:
🧩 Hat Blocks
Rounded tops - These start your scripts! Like “when green flag clicked” or “when space key pressed.”
📦 Stack Blocks
Rectangular with notches - These are action blocks that fit together like puzzle pieces. Most blocks are stack blocks.
🔘 Boolean Blocks
Pointed/hexagonal shape - These answer yes/no questions. Like “touching mouse pointer?” or “key space pressed?”
🟫 Reporter Blocks
Rounded rectangles - These give you information like numbers or text. Like “mouse x” or “answer.”
🏁 Cap Blocks
Flat bottoms - These end your scripts. Like “stop all” blocks that can’t have anything attached below.
Let’s build a script step by step with Vibelf’s guidance:
🎬 Start with a Hat Block Every script needs a beginning! Drag “when green flag clicked” from Events to your scripts area.
➕ Add Action Blocks Stack blocks underneath by snapping them together. The white line shows where blocks will connect.
🔧 Customize with Inputs Click on the white circles or rectangles to change numbers, select options, or type text.
🔄 Test and Adjust Run your script and see what happens. Programming is all about experimenting!
when green flag clickedsay [Hello! I'm learning Scratch!] for (2) secondsmove (50) stepsturn ↻ (90) degreessay [Programming is fun!] for (2) seconds
Let’s explore how different block types work together:
move (10) steps - Makes your sprite walk forward
turn ↻ (15) degrees - Rotates your sprite clockwise
turn ↺ (15) degrees - Rotates your sprite counter-clockwise
go to x:(0) y:(0) - Moves sprite to exact coordinates
glide (1) secs to x:(0) y:(0) - Smoothly moves over time
point towards (mouse-pointer ▼) - Aims sprite at target
if on edge, bounce - Keeps sprite on stage
set rotation style (left-right only ▼) - Controls how sprite rotates
💬 Speech and Thought
Make sprites communicate with speech bubbles or thought bubbles. Perfect for storytelling!
🎭 Costume Changes
Switch between different looks for your sprite. Create animations by changing costumes quickly!
✨ Visual Effects
Apply color effects, change size, or make sprites transparent. Add magic to your projects!
👁️ Visibility
Show or hide sprites, and control which layer they appear on.
Control blocks are like the conductor of an orchestra - they decide when and how other blocks run:
repeat (10) move (10) steps wait (0.1) seconds
This makes your sprite take 10 small steps with a pause between each one.
forever if <touching (mouse-pointer ▼)?> then say [You found me!] for (1) seconds end
This continuously checks if the mouse is touching the sprite.
if <key (space ▼) pressed?> then jump 50 pixels play sound (pop ▼) until doneelse say [Press space to jump!]end
Variables are like your sprite’s memory:
set [score ▼] to (0)change [score ▼] by (10)say (join [Your score is ] (score)) for (2) seconds
Use sensing blocks to respond to the user:
when this sprite clickedask [What's your name?] and waitsay (join [Hello ] (answer)) for (3) seconds
Use broadcast messages to make sprites work together:
// Sprite 1 (Director)when green flag clickedbroadcast (start game ▼)
// Sprite 2 (Actor)when I receive (start game ▼)say [The game begins!] for (2) seconds
Here are some useful patterns you’ll use often:
when green flag clickedforever next costume wait (0.2) seconds
when green flag clickedforever if <key (up arrow ▼) pressed?> then move (5) steps end if <key (down arrow ▼) pressed?> then move (-5) steps end
when green flag clickedforever if <touching (sprite2 ▼)?> then say [Ouch!] for (1) seconds go to x:(0) y:(0) end
When your script doesn’t work as expected, try these debugging strategies:
👀 Watch Your Script Run Click on individual blocks to see what each one does.
🐌 Slow It Down Add “wait (0.5) seconds” blocks to see what’s happening step by step.
💬 Add Say Blocks Use “say” blocks to display variable values and see what your program is thinking.
🔄 Test Small Pieces Run small parts of your script separately to find where problems occur.
📝 Use Comments Add yellow comment blocks to explain what each part of your script should do.
Keep your scripts neat and organized:
Put scripts that work together near each other in the scripts area.
When creating custom blocks or variables, give them clear, descriptive names.
Explain tricky parts of your code with comment blocks.
Delete scripts you’re no longer using to keep your project tidy.
Now that you understand blocks and scripts, you’re ready for bigger challenges:
Remember: Every expert programmer started with simple blocks and scripts. With Vibelf’s AI guidance and your creativity, you’re building the foundation for amazing digital creations! ✨