Health bar help.

I have a problem with my HUD. I want it so as health decreases, the bar goes down, and as health increases it goes up. But what happens is as health decreases the bar goes from the bottom to the top, not top to bottom. This is what I mean:

http://img594.imageshack.us/img594/5996/problemhudhealth.jpg

So how can I get the health bar to go from top to bottom as health decreases? Here is my code:

[lua]function HUD()
local hp = ( LocalPlayer():Health() * ScrH() * 0.0020 )

draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79, ScrW() / 35, ScrH() / 5, Color( 100, 100, 100, 255 ) )
draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79, ScrW() / 35, hp, Color( 255, 0, 0, 255 ) )

end
hook.Add( “HUDPaint”, “HUD”, HUD )[/lua]

You would need to make the red part go down at the same rate.

How would I do that?

Bump. Still waiting for an answer.

A snippet I did from my edited TS2

[lua]
local plyhealth = LocalPlayer():Health();
draw.RoundedBox( 2, 420, 156 + 100 - plyhealth, 7, 25 + plyhealth, Color( 130, 0, 0, 255 ) );
draw.RoundedBox( 2, 420, 156 + 100 - plyhealth, 4, 25 + plyhealth, Color( 170, 0, 0, 255 ) );
[/lua]

Should work.

Yours didn’t work, H0rey. Plus, I have to change the x and y and width and height because I need to use ScrW() and ScrH() to make it the same on each screen, which messes it up.

Try:
[lua]
draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79, ScrW() / 35, ScrH() / 5, Color( 100, 100, 100, 255 ) )
draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79 - (ScrH() / 5 - hp), ScrW() / 35, hp, Color( 255, 0, 0, 255 ) )
[/lua]
or something

[lua]function HUD()
local hp = ( LocalPlayer():Health() * ScrH() * 0.0020 + 30 )

draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79, ScrW() / 35, ScrH() / 5, Color( 100, 100, 100, 255 ) )
draw.RoundedBox( 4, ScrW() * 0.97, ScrH() * 0.79 + 100 - LocalPlayer():Health(), ScrW() / 35, hp, Color( 255, 0, 0, 255 ) )

end
hook.Add( “HUDPaint”, “HUD”, HUD )[/lua]

That should work…

Replace the “100 - LocalPlayer():Health()” with “LocalPlayer():GetMaxHealth() - LocalPlayer():Health()”.

H0rsey, if I have ( LocalPlayer():Health() * ScrH() * 0.0020 + 30, I think that would mess up the sizing for it because of the 30. From recent mistakes, I cannot have addition or subtraction when sizing or positioning because it won’t be the same for everyone.

It will never truly be the same for everyone, but addition is fine in some cases.