All Activities

Script to Kill a Player

Script to Kill a Player
Green highlight

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.

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

Step-by-step guide to Script to Kill a Player

What you need
Scratch editor open, player sprite, enemy sprite, a 'game over' costume for the player sprite, a game over sound (optional)

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.

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

0:00/0:00

Here at SafeTube, we're on a mission to create a safer and more delightful internet. ๐Ÿ˜Š

Roblox Studio Basics - Roblox Beginners Scripting Tutorial #1 (2025)

4 Videos
Roblox Studio Basics - Roblox Beginners Scripting Tutorial #1 (2025)

Roblox Studio Basics - Roblox Beginners Scripting Tutorial #1 (2025)

How To Make A Video Game - GDevelop Beginner Tutorial

How To Make A Video Game - GDevelop Beginner Tutorial

How to Make a Fighting Game in Scratch

How to Make a Fighting Game in Scratch

How To Make A Game - Step By Step Tutorial [1]

How To Make A Game - Step By Step Tutorial [1]

Facts about game programming with Scratch

๐Ÿฑ 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.

๐Ÿ” "Respawn" means a player returns to play after being defeated; many games use checkpoints so you restart nearby instead of from the very beginning.

๐ŸŽฌ 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.

๐Ÿงฉ Scratch uses block-based, event-driven coding โ€” you can broadcast messages (like "playerDied") to play an animation and reset health safely.

How do I make a Scratch script that makes the player's character lose all health, play a safe 'game over' animation, and respawn?

To make this in Scratch, create a 'health' variable and set it to the max at start. When a hit occurs, use 'set health to 0' or 'change health by -health', then broadcast 'game over' and switch to a gentle game-over costume or play an animation. Stop player controls, play a short sound, wait 2โ€“3 seconds, then reset health, move the sprite to a respawn position, and broadcast 'respawn' to re-enable controls.

What materials and tools do I need to build a script in Scratch that reduces a player's health to zero, shows a gentle 'game over', and respawns them?

You need a computer or tablet with internet (or the offline Scratch editor), a Scratch 3.0 account or editor, and a project with a player sprite. Add costumes for the game-over animation and respawn, simple sounds, and a 'health' variable. Optional: keyboard/gamepad for testing, pen and paper for planning, and adult help for younger kids.

What ages is this Scratch lesson suitable for?

Scratch projects like this work well for children about 8โ€“14 years old. Younger kids (5โ€“7) can participate with adult guidance for block placement and testing. Teens can add features like health bars, invincibility frames, or multiple lives. Also teach debugging and problem-solving to build confidence and coding skills.

Are there safety tips or best practices when creating a 'game over and respawn' script in Scratch?

Keep animations and language non-graphic and friendly: use 'game over' screens, cartoon effects, or 'try again' messages. Teach kids to separate in-game defeat from real-life harm. For shared projects, remove player names and avoid realistic violence. Supervise younger children, review any comments, and emphasize learning, debugging, and resilience over violent wording.

Ready to create?

Drop Files here
Make

To create a safe space for kid creators worldwide!

Create

Vibe Coding

Kids GPT

All Tools

Kibu

Resources

Worksheets

SafeTube

Blog

FAQ

Account

Pricing

Log-in

Sign-up

Data Deletion

Company

About

Community Guidelines

Privacy Policy

Terms of Service

2025, URSOR LIMITED. All rights reserved. DIY is in no way affiliated with Minecraftโ„ข, Mojang, Microsoft, Robloxโ„ข or YouTube. LEGOยฎ is a trademark of the LEGOยฎ Group which does not sponsor, endorse or authorize this website or event. Made with love in San Francisco.