Scratch Tutorial 3

How to Make a Custom Player HP / Health System

  1. Step 1: Setting up Lives

    Scratch Variable Setup with Green Flag

    Go to the Variables block tab, click Make a Variable, and name it HP. Now create your first block chain. Place a when green flag clicked block into your player sprite workspace, followed instantly by a set [HP v] to (3) block right underneath it.

  2. Step 2: Hit Detector Check

    Scratch Collision Loop inside Forever block

    Inside the player's primary `forever` movement loop from Tutorial 1, drop an if then and forever conditional frame block to scan for incoming damage: if <touching [Enemy v]?> then.

  3. Step 3: Cooldown Window

    Scratch Damage reduction and cooling timer block

    Inside that damage check frame, reduce a heart container by adding a change [HP v] by (-1) block. Drop a wait (1) seconds block directly underneath it to create invincibility frames so your lives don't hit zero instantly!

  4. Step 4: Game Over Loop

    Scratch Stop block execution sequence

    Finally, we need a separate script chain to monitor death. Create a brand new when green flag clicked trigger block. Attach a wait until <(HP) < (1)>> conditional block, and drop a stop [all v] component at the base to end the game loop cleanly.

HP Mechanics Completed! 🎮

Your game layout now has real structural stakes! Users have to actively dodge the incoming tracking entities while monitoring their active health bar indicators.

← Go to Home