'Each player has a different amount of energy' - that's the variable maxHP in my example
calculate hp% = hp/maxHP*100
So if hp is 5 and max is 10 then hp% = 50
if hp is 5 and max is 100 then hp% = 5
if hp is 10 and max is 10 then hp% = 100
if hp is 2 and max is 2 then hp% = 100
Set the bar width to hp% (it'll be from 0 to 100)