Strange error

Ok so I have spent a good hour looking this over and over and I can’t figure out what’s wrong. Sometimes my Swep gets an error at line 142. Well this is part of my Primary function, here it is:
[lua]function SWEP:PrimaryAttack()
if( CurTime() < self.NextStrike ) then return; end
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
local trace = self.Owner:GetEyeTrace()
local Pos1 = trace.HitPos + trace.HitNormal
local Pos2 = trace.HitPos - trace.HitNormal
local phys = trace.Entity:GetPhysicsObject() – Line 142 here
if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 70 then
if(ValidEntity( trace.Entity ) and table.HasValue( self.Fleshy, trace.Entity:GetClass( ) ) or trace.Entity:GetClass()==“prop_ragdoll” or trace.Entity:IsPlayer()) then
self.Weapon:EmitSound( self.FleshHit[math.random(1,#self.FleshHit)] );
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
elseif(ValidEntity( trace.Entity ) and table.HasValue( self.Machinery, trace.Entity:GetClass() ) ) then
self.Weapon:EmitSound( self.Hit[math.random(1,#self.Hit)] );
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
elseif trace.Entity:GetClass() == “prop_physics” then
phys:ApplyForceOffset(self.Owner:GetAimVector():GetNormalized() * math.random(1500, 2000), trace.HitPos)
if SERVER then
trace.Entity:SetVelocity(self.Owner:GetAimVector():GetNormalized() * math.random(1500, 2000))
end
util.Decal(“ManhackCut”, Pos1, Pos2)
self.Weapon:EmitSound( self.Hit[math.random(1,#self.Hit)] );
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
elseif trace.Entity:GetClass() == “prop_ragdoll” then
self.Owner:FireBullets(decal)
phys:ApplyForceOffset(self.Owner:GetAimVector():GetNormalized() * math.random(3000, 5000), trace.HitPos)
if SERVER then
trace.Entity:SetVelocity(self.Owner:GetAimVector():GetNormalized() * math.random(3000, 5000))
end
self.Weapon:EmitSound( self.FleshHit[math.random(1,#self.FleshHit)] );
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
else
self.Weapon:EmitSound( self.Hit[math.random(1,#self.Hit)] );
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
util.Decal(“ManhackCut”, Pos1, Pos2)
end
timer.Simple( 0.05, function()
if SERVER then
trace.Entity:TakeDamage(math.random(15,30), self.Owner, self.Owner)
end
end)
end
timer.Simple(0.4,function() self.Weapon:SendWeaponAnim( ACT_VM_DRAW ) end )
timer.Simple(1.4,function() self.Weapon:SendWeaponAnim( ACT_VM_IDLE ) end )
self.Weapon:EmitSound(“weapons/wrench/swing.wav”)
self.NextStrike = ( CurTime() + 1.5 )
end[/lua]
Please help.

It would help greatly if you would tell us what the error is rather than just saying “go for it”.

But your issue is probably whatever you’re looking at doesn’t have a physics object or isn’t an entity. If you’re looking at the world, it probably doesn’t have a physics object. So, before you try and to stuff with whatever entity you’re looking at, make sure it’s valid with ValidEntity.

[lua]
if !trace.Entity && !IsValid(trace.Entity) then return end
[/lua]