Health bar wont work

I have a health bar in my game but for for reason the code below doesnt work when i put it in an if statement.

health.bar.width -= (player.hp / maxHP)