Custom hud help

Hello, I am working on a custom hud while I am learning lua. I am using codeblues guide as a refernce so if there is a better way of scripting a hud, or my code is ugly for w/e reason please let me know so I can kick the bad habits early, thank you.


surface.CreateFont( "Test.font", {
	font = "Arial",
	extended = false,
	size = 20,
	weight = 1000,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = false,
	additive = false,
	outline = false,
} )

hook.Add("HUDPaint" , "DrawMyHud" , function()

	local health = LocalPlayer():Health()
	local armor = LocalPlayer():Armor()

	if health <= 0 then

		health = 0

	end

	if armor <= 0 then

		armor = 0

	end

	-- Base
	draw.RoundedBox(5,(ScrW() / 2) - 400,0 - 5,800,30,Color(100,100,100))

	-- Health
	draw.RoundedBox(5,(ScrW() / 2) - 395,0 - 10,(health * 3.95),30,Color(255,140,140))
	draw.SimpleText("HP: "..health,"Test.font",(ScrW() / 2) - 360, 10,Color(255,255,255),1,1)

	-- Armor
	draw.RoundedBox(5,(ScrW() / 2) + 5,0 - 10,(armor * 3.9),30,Color(140,140,255))
	draw.SimpleText("Armor: "..armor,"Test.font",(ScrW() / 2) + 55,10,Color(255,255,255),1,1)
end)

My question is why there are the red and blue is still showning when the x values are 0. I clearly dead, and the health/armor variables are being called in the draw.RoundedBox(). They are zero because I am dead, and they should still remain zero because 0 * anything is still 0.

I am just beginning lua so you can rate this post dumb I don’t really care.

Thanks in advance for any help.

EDIT:

Just now saw garry’s post about help/support. Creating a new thread over there this can be deleted or closed Sorry :stuck_out_tongue: