Make a sprite with multiple frames.
Frame 0: make it have a sprite with 3 hearts(you can make the sprite look how ever u want but just make sure the player can see the change in it as the take damage)
frame 1: 2 hearts
frame 2: 3 hearts
When playerhp=3 set animation frame to 2
When playerhp=2 set frame to 1
When playerhp=1 set frame to 0
when playerhp=0 destroy player/end game/respwan( what ever your end game is set to be)