Alright so I need some help trying to understand how to make it so the health bar does not go off the screen (that is what its doing) now I went on the gmod wiki and found the mathClamp thing but I could not make sense of it. If someone could explain it or have a different aproach to it please tell me
here is the code:
local health = LocalPlayer():Health() or 0 if health > 100 then health = health end if health < 0 then health = 0 end if health != 0 then surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( red ) surface.DrawTexturedRect( ScrW() / 11.5, ScrH () / 1.265, health * 3.1, 47) end
Now I want it to write down the HP but I don’t want the bar to go off the screen.