I hate to post out in public. But I cannot figure this out. I’m trying to get the ammo value text to vanish, Once the amount has hit 0. But, Instead. it gives me an error saying
“Hook ‘myhud’ Failed: ****/gamemode/cl_init.lua:94: attempt to compare nil with number”
function myhud()
local client = LocalPlayer()
if !client:Alive() then return end
if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end
cash = client:GetNWInt("money")
draw.RoundedBox(0, 5, 650, 200, 100, Color(0, 0, 0, 155))
draw.SimpleText("Health: "..client:Health(), "ScoreboardText", 10, 655, Color(175, 0, 0, 255), 0, 0)
if magleft < 1 then -- <-- here is where I have the value.
draw.SimpleText("Ammo: "..client:GetActiveWeapon():Clip1().."/"..client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()), "ScoreboardText", 10, 670, Color(150, 150, 150, 255), 0, 0)
end
draw.SimpleText("Cash: ".."$"..cash, "ScoreboardText", 10, 685, Color(0, 205, 0, 255), 0, 0)
local magleft = client:GetActiveWeapon():Clip1() -- How much ammunition you have inside the current magazine
local magextra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()) -- How much ammunition you have outside the current magazine
local secondaryammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType())-- How much ammunition you have for your secondary fire, such as the MP7's grenade launcher
end
hook.Add("HUDPaint", "myhud", myhud)
Any help would be appreciated.