Can't get hud to show "Reserve" ammo

This is my second post today sorry for posting twice in a day! Won’t happen again I just can’t seem to figure this out.
right now this is what I have


	local currentammo = LocalPlayer():GetActiveWeapon():Clip1()
	local maxammo = LocalPlayer():GetActiveWeapon():GetMaxClip1()
	local wname = LocalPlayer():GetActiveWeapon():GetPrintName()
	draw.RoundedBox(1,ScrW() - 210,ScrH() - 90, 200, 80, Color(0, 0, 0, 200))
	draw.SimpleText(currentammo.."/"..maxammo,"DermaLarge", ScrW() - 200, ScrH() - 86, color_white, TEXT_ALIGN_LEFT)
	draw.SimpleText(wname,"DermaLarge", ScrW() - 200, ScrH() - 45, color_white, TEXT_ALIGN_LEFT)
end

I currently have trouble with the getting the HUD to display the amount of unused ammo you have on your player, I’m aware that right now it’s showing the max amount you can have in the clip. I can’t figure it out, everytime I try I get errors

btw this is just a snippet of code not the whole thing which is why there’s a straggling “end”

You want to use Player:GetAmmoCount() and Weapon:GetPrimaryAmmoType() instead of Weapon:GetMaxClip1().


Got this in return [ERROR] addons/solohud/lua/autorun/client/cl_solohud.lua:114: attempt to index global 'Player' (a function value)
  1. v - addons/solohud/lua/autorun/client/cl_solohud.lua:114
   2. unknown - lua/includes/modules/hook.lua:84

and here what I put in. I just created another variable for it


local resammo = Player:GetAmmoCount(Weapon:GetPrimaryAmmoType())

The “Weapon” refers to the weapon entity, and “Player” refers to a current player variable.

Since you’re doing clientside code, you can use LocalPlayer() to retrieve the current player.
Player:GetActiveWeapon() is a function you can also use to find out the current weapon the player has.

This


local ply = LocalPlayer()
local wep = ply:GetActiveWeapon()
local ammotype = wep:GetPrimaryAmmoType()
local remammo = ply:GetAmmoCount( ammotype )


print( remammo )

is the same as this



local ply = LocalPlayer()
print( ply:GetAmmoCount( ply:GetActiveWeapon():GetPrimaryAmmoType() ) )

Both return the same result.

Basically, what you’re doing is grabbing the local player, then grabbing his currently equipped weapon, checking what kind of ammo it uses, and how much of that ammo type the player currently has.

Actually I got passed the ‘Player’ part but now I have



[ERROR] addons/solohud/lua/autorun/client/cl_solohud.lua:116: attempt to index global 'Weapon' (a nil value)
  1. v - addons/solohud/lua/autorun/client/cl_solohud.lua:116
   2. unknown - lua/includes/modules/hook.lua:84


[editline]19th November 2015[/editline]

I understand how it works, I just wasn’t putting the local player as variable in front of the


GetActiveWeapon()

So I was using this


print( ply:GetAmmoCount(GetActiveWeapon():GetPrimaryAmmoType() ) )

thinking that the system would know that I was still talking about the local player