Create Health bar that changes color

im beginner in coding
im using rts engine for learning purpose
so im asking can somebody help me create simple script
that health bar changes when you take damage
like this
100% green bar
50% yellow bar
25% Red bar
and is there any tutorial to make script that units return to warfactory after the have too much damage at 25% to go back to warfactory for repair

7439039--911747--Screen Shot 2021-08-22 at 7.50.34 AM.jpg