After coding nearly all day long today, my HUD is close to being done! However, there’s another issue.
// Right panel local INFO = vgui.Create("DPanel", HUDF) INFO:Dock(FILL) function INFO:Think() function INFO:Paint(w,h) surface.SetDrawColor(Color(0,0,0,150)) surface.DrawRect(10,10,230,140) //Heart icon surface.SetDrawColor(Color(250,128,114)) surface.SetMaterial(hearticon) surface.DrawTexturedRect(15,15,32,32) //Armor icon surface.SetDrawColor(Color(65,105,225)) surface.SetMaterial(shieldicon) surface.DrawTexturedRect(15,50,32,32) //Health bar if health > 0 then draw.RoundedBox(3,52,28,health * 1.8,5,Color(250,128,114)) elseif health > 100 then draw.RoundedBox(3,52,28,180,5,Color(250,128,114)) else end //Armor bar draw.RoundedBox(3,52,68,armor * 1.8,5,Color(65,105,225)) end end
Basically what I am trying to do is prevent my HUD from glitching out when someone has more than 100 health.
Also, because of roundedbox, at 0 health it still shows a small drawing of only the roundings, so I’m trying to tell lua that if the health is not bigger than 0 it wont do anything.
Then I used the Think() version to check for updates in health constantly, but it does not work for some reason.
Help’d be appreciated!