I feel like an idiot not being able to figure this out (SWEP)

Hey guys.

So I’m working on a first draw code that plays a different animation on the first time you deploy the weapon. What I had was:


firstTime = 0

function SWEP:Deploy()
	if firstTime == 0 then
	self:SendWeaponAnim(ACT_VM_DRAW_FIRST)
	firstTime = 1
	return true
else
	self:SendWeaponAnim(ACT_VM_DRAW_NORMAL)
	return true
	end
end

which works fine, but doesn’t reset firstTime to 0 on playerdeath. So being the dunce I am (that can’t think of any other ways) made this


firstTime = 0 -- line 66

function checkDead()
	if !self.Owner:Alive() then -- line 69
	firstTime = 0
	return true
else
	return false
	end
end

function SWEP:Deploy()
	if checkDead() and firstTime == 0 then -- line 78
	self:SendWeaponAnim(ACT_VM_DRAW_FIRST)
	firstTime = 1
	return true
else
	self:SendWeaponAnim(ACT_VM_DRAW_NORMAL)
	return true
	end
end -- line 86

Error.



[ERROR] addons/whoops/lua/weapons/weapon_dinkle/shared.lua:69: attempt to index global 'self' (a nil value)
  1. checkAlive - addons/whoops/lua/weapons/weapon_dinkle/shared.lua:69
   2. unknown - addons/whoops/lua/weapons/weapon_dinkle/shared.lua:78




function SWEP:Deploy()
	if !self.firstTime then
		self:SendWeaponAnim(ACT_VM_DRAW_FIRST)
		self.firstTime = true
		return true
	end
	self:SendWeaponAnim(ACT_VM_DRAW_NORMAL)
	return true
end

Thank you. I knew I was missing something >>