ERROR: Hook 'ProfEvener' Failed: [lua\weaponprofeven.lua:9] attempt to call method 'GetActiveWeapon' (a nil value)

Title says the problem. I’m trying to make the code not execute when the NPC has a grenade because it causes the code to return a nil value ending the script :\


if NPC:GetActiveWeapon():IsValid() && NPC:GetActiveWeapon() != "weapon_frag" then

(User was banned for this post ("Wrong section" - Gran PC))

What is NPC defined as?

All current NPC’s.

NPCS = ents.FindByClass( "npc_*" )
	if  #NPCS == 0 then end
	for i=1,#NPCS do

And I feel like a dumbass now because I failed to read the big sticky and will probably be banned for this post…

EDIT: If it helps, it worked before I added that part of the script, and it fails when they throw a grenade.

EDIT2: Hah! I fixed it. It turns out that active grenades are NPC’s.