GLua: Why not painting the hood at the entrance to the map?

I wrote a simple hood, like errors is not present, well only 1, but it's kind of like a baby :)
Here is the code:
if !ply:IsValid() then return end

 hp = ply:Health()
 if hp < 0 then hp = 0 end

 mx = ply:GetMaxHealth()

 ar = ply:Armor()
 if ar == 0 then ar = "; ar2 = 0 else ar2 = ar end

 sh = '/'
 am = ply:GetActiveWeapon():Clip1()
 if am < 1 then am = "; sh = " end
 sa = ply:GetAmmoCount( ply:GetActiveWeapon():GetPrimaryAmmoType() )
 if sa < 1 then sa = "; sh = " end

 wp = ply:GetActiveWeapon():GetPrintName()
 nm = ply:Name()

 draw.RoundedBox(5, x - 10, y - 50, 220, 140, Color(0, 0, 0, 200))
 draw.RoundedBox(5, x - 10, y - 50, 220, 40, Color(0, 0, 0, 200))
 draw.SimpleText(nm, 'NameFont', x + 100, y - 30, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

 draw.RoundedBox(2, x, y, 200, 30, Color(150, 50, 0, 250))
 draw.RoundedBox(2, x , y, math.Clamp(hp, 0, 100) * 2, 30, Color(250, 50, 0, 250))
 draw.SimpleText(hp, 'HudFont', x + 100, y + 15, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

 draw.RoundedBox(2, x, y + 50, 200, 30, Color(0, 50, 150, 250))
 draw.RoundedBox(2, x, y + 50, math.Clamp(ar2, 0, 100) * 2, 30, Color(0, 50, 250, 250))
 draw.SimpleText(ar 'HudFont', x + 100, y + 65, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

 draw.RoundedBox(5, x2 - 10, y2 - 10, 220, 100, Color(0, 0, 0, 200))
 draw.RoundedBox(5, x2 - 10, y2 - 10, 220, 50, Color(0, 0, 0, 200))
 draw.SimpleText(wp, 'NameFont', x2 + 100, y2 + 15, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
 draw.SimpleText(am sa.., sh.., 'HudFont', x2 + 100, y2 + 65, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

The code runs on the hook HUDPaint. Please help!
And Yes, this is an error if:
[ERROR] addons/minimal hud/lua/autorun/cl_init.lua:10: attempt to index global 'surface' (a nil value)
1. unknown - addons/minimal hud/lua/autorun/cl_init.lua:10
April 19th 20 at 12:43

Find more questions by tags Lua