on join:
set {bossbar::%player%} to new boss bar
add player player to {bossbar::%player%}
on damage:
victim is not a player
set {_bossbar} to {bossbar::%attacker%}
show boss bar {_bossbar}
set {_health} to health of victim / max health of victim - 0.1 # Boss Bar progress is in between 0 and 1. 0.5 = 50% etc.
set bar progress of {_bossbar} to {_health}
set bar title of {_bossbar} to "&b&l%victim%"
if {_health} is equal to 0.7 or 0.6 or 0.5:
set bar color of {_bossbar} to yellow
else if {_health} is equal to 0.4 or 0.3 or 0.2 or 0.1 or 0:
set bar color of {_bossbar} to red
else if {_health} is greater than 0.7:
set bar color of {_bossbar} to green
wait 5 seconds
hide boss bar {_bossbar}