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.
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.
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!
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.
Your game layout now has real structural stakes! Users have to actively dodge the incoming tracking entities while monitoring their active health bar indicators.