Getting Client Ammo Amounts

I’ve tried the code suggested on the wiki:
(With pl defined as LocalPlayer() )

And I keep getting the error 'Hook ‘<Hook Name>’ Failed: <Gamemode Name>\gamemode\cl_gui.lua:92: attempt to call method ‘GetPrimaryAmmoType’ (a nil value)

I see no immediate problem with your script. The way I usually get myself out of these is using print() to debug.
Right now it says it’s calling a nil method even tough you know it exists. That usually means it’s not being called on what you are expecting it to. Try printing the result of GetActiveWeapon() to see if it really is a weapon. This is why you would also check if the active weapon is valid before trying to get it’s ammo count. Maybe at the time of calling the hook the player had no weapons or they were somehow invalid.

Oh and please don’t censor out the hook name. This will only make it harder for us to help you.

The hook name is just the name I gave my HUD hook. It is of no importance.
I’ll try adding a check to see if the weapon is valid.


Ugh, HURR!
xD That’s what it was…