• SWEP "self" Inheritance Not Working
    1 replies, posted
Please nobody fix this for me, please explain it. I want to understand what's wrong, not have someone code it for me. [CODE]function SWEP:BaseAttack() burstfire = burstfire + 1 if not self:CanPrimaryAttack() then return end if CLIENT then self.Weapon:EmitSound( self.Primary.Sound, self.Primary.SoundLevel ) elseif SERVER then sound.Play(self.Primary.Sound, self:GetPos(), self.Primary.SoundLevel) end self:ShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self:GetPrimaryCone() ) self:TakePrimaryAmmo( 1 ) local owner = self.Owner if not IsValid(owner) or owner:IsNPC() or (not owner.ViewPunch) then return end owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) ) end[/CODE] Error: [CODE][ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_m16/shared.lua:57: attempt to index local 'self' (a nil value) 1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_m16/shared.lua:57 [/CODE] I interpret this to mean "self" is not pointing to the SWEP like it's supposed to, but the exact same syntax works in neighboring functions. Is there a reason self isn't working?
Which line is 57?
Sorry, you need to Log In to post a reply to this thread.