So I have a lot of repeat type of code, example below, and I’m just wondering if there is any way to simplify it
This for some reason really bothers me, and if there is anyway to make it into one function please let me know
Code:
if plyHealth != 0 then
draw.RoundedBox(0, ScrW() / 2 - 175, ScrH() - 45, (350) * plyHealth / 100, 25, Color(255,255,255,50), TEXT_ALIGN_CENTER)
end
if plyHealth <= 75 then
draw.RoundedBox(0, ScrW() / 2 - 175, ScrH() - 45, (350) * plyHealth / 100, 25, Color(255,112,112,255), TEXT_ALIGN_CENTER)
end
if plyHealth <= 50 then
draw.RoundedBox(0, ScrW() / 2 - 175, ScrH() - 45, (350) * plyHealth / 100, 25, Color(255,91,91,255), TEXT_ALIGN_CENTER)
end
if plyHealth <= 25 then
draw.RoundedBox(0, ScrW() / 2 - 175, ScrH() - 45, (350) * plyHealth / 100, 25, Color(255,58,58,255), TEXT_ALIGN_CENTER)
end
if plyHealth <= 10 then
draw.RoundedBox(0, ScrW() / 2 - 175, ScrH() - 45, (350) * plyHealth / 100, 25, Color(221,17,17,255), TEXT_ALIGN_CENTER)
end