Write a simple game script in Scratch that causes a player's character to lose all health, play a safe 'game over' animation, and respawn.



Step-by-step guide to Script to Kill a Player
Step 1
Open Scratch and start a new project.
Step 2
Choose or draw the sprite you want to be the player.
Step 3
Move the player sprite to the exact spot where you want it to come back after a game over and remember the x and y numbers.
Step 4
Make a new variable named health and set it to be for this sprite only.
Step 5
Add a "when green flag clicked" script to the player sprite.
Step 6
Under that "when green flag clicked" add blocks to set health to 100 and to go to the spawn x y position you remembered.
Step 7
Add a forever loop under the green flag script and inside it put an if block that checks "touching [enemy]?".
Step 8
Inside that if block add a block to set health to 0 and then add a block to broadcast "gameOver".
Step 9
Make a "when I receive [gameOver]" script on the player that switches to the game over costume then plays the game over sound until done then goes to the spawn x y and sets health back to 100 and finally switches back to the normal costume.
Step 10
Test your game by clicking the green flag and causing the player to touch the enemy to see health go to 0 play the safe game over animation and respawn and then share your finished creation on DIY.org.
Final steps
You're almost there! Complete all the steps, bring your creation to life, post it, and conquer the challenge!


Help!?
What can I use if I can't find an 'enemy' sprite or a game over sound in Scratch?
Use any built-in sprite (for example 'Ghost' or 'Ball') and either pick a sound like 'pop' from the Sounds tab or record your own, then change the touching [enemy]? block and the 'play sound (game over) until done' block to the names you chose.
My player doesn't respawn or play the game over animation when it touches the enemy—what should I check?
Make sure the 'set health to 0' and 'broadcast gameOver' blocks are inside the if touching [enemy]? in the forever loop, the variable 'health' was created 'for this sprite only', the broadcast name exactly matches the 'when I receive [gameOver]' script on the player, and the 'go to x y' uses the exact spawn x and y you recorded.
How can I make this activity easier for younger kids or harder for older kids?
For younger kids, replace the health variable with a simple 'lives' variable set to 3 and broadcast gameOver only when lives = 0, while older kids can use 'change health by -20' on touch, add a visible health bar sprite that resizes, and implement temporary invincibility after respawn.
What are some ways to extend or personalize the game before sharing it on DIY.org?
Add a score variable, multiple enemy sprites with different damage values and costumes, an animated game over backdrop and custom sound in the 'when I receive [gameOver]' script, or create power-ups that change the player's costume and health behavior before sharing.
Watch videos on how to Script to Kill a Player
Facts about game programming with Scratch
🔁 "Respawn" means a player returns to play after being defeated; many games use checkpoints so you restart nearby instead of from the very beginning.
🧩 Scratch uses block-based, event-driven coding — you can broadcast messages (like "playerDied") to play an animation and reset health safely.
🐱 Scratch's default sprite is the orange "Scratch Cat" — it's the playful mascot kids often start coding with.
🎮 The idea of "hit points" came from tabletop role-playing games and is now a core way video games track a character's health.
🎬 The phrase "Game over" became famous in early arcade games, but friendly "game over" animations (like a gentle fade or sad wave) keep games fun for kids.


Only $6.99 after trial. No credit card required