Can someone tell me whats wrong with this piece of code
1 replies, posted
This is part of a cloudscript i'm working with:
[lua]
function ENT:Shoot( pl )
local ang, muzzle
if not self.FakeGun.Muzzle then
self.FakeGun.Muzzle = self.Gun:LookupAttachment( "Muzzle" )
end
WorldSound( "npc/strider/strider_minigun.wav", pl:GetShootPos( ) + pl:GetRight( ) * 32 )
//if CLIENT then
// print ( ToString( "say ", self.Spinup ) )
//end
muzzle = self.FakeGun:GetAttachment( self.FakeGun.Muzzle )
ang = pl:GetAimVector( ):Angle( )
ang:RotateAroundAxis( ang:Up( ), 90 )
self.Bullet.Src = muzzle.Pos
self.Bullet.Attacker = pl
self.Bullet.Dir = pl:GetAimVector( )
self.Bullet.Force = 900
self.Bullet.Spread = Vector( ) * math.sin( math.rad( 0 ) )
self.Bullet.Num = 1
self.Bullet.Damage = 300
self.Bullet.Tracer = 1
//self.Bullet.AmmoType = "LaserTracer"
self.Gun:FireBullets( self.Bullet )
end
[/lua]
It keeps giving me this error:
[!toybox_3107_234:182] attempt to index local 'muzzle' (a nil value)
That means
[code] muzzle = self.FakeGun:GetAttachment( self.FakeGun.Muzzle )[/code]
is nil. Meaning self.FakeGun, self.Gun, or self.FakeGun.Muzzle are not working. Check to make sure those are as they should be.
Sorry, you need to Log In to post a reply to this thread.