There's a few different ways to accomplish this.
Setting up the heart containers.
One next trick is to create your heart sprite in a tiled background object instead of as a normal sprite. Then you set the width to X times the width of the heart times the number of lives the player has.
eg: if the heart is 64 pixels wide. Each time you increase the width of the tiled background heart container by 64 pixels, another heart will appear or disappear. (make sure you set the origin point of the object to the left or top left of the sprite so that it will scale properly.
Subtracting the lives
Create a global variable called "Lives" and give it an initial value of 3 lets say.
Event 1
On start of layout -> Set width of HeartContainer to Lives * 64 (or whatever width your heart is)
Event2
(Player) Is outside of layout
AND
(system)Trigger once while true
-> subtract from "Lives" 1
-> Set width of HeartContainer to Lives * 64 (or whatever width your heart is)
Event 3
(system) Lives = 0 -> goto layout "Game Over"
Voila!