If by "equal to 5" you mean 2.5 heart icons, then you need to do a little rounding... PHP: $displayed_health = (int) ceil($player->getHealth());return $displayed_health === 5; What's wrong with $player->getHealth() == 5? Health points are stored as float. The player could have 4.99 or 4.75 health points yet it would show up as 2.5 hearts to the player.
PHP: $player = $event->getPlayer(); if ($player->getHealth() == 5) { //do stuff } if ($player->getHealth() < 5) { //do stuff }