Help implementing Player.TraceHullAttack to a basic SWEP

**Objective: **I’m totally new to this and want to create a SWEP that shoots a volume rather than a line. Like a laser type of thing (I know I’d have to add a sprite as well)

So I read both the SWEP framework and example:

and tried to implement this:

but it comes up with this:

**Error: ** attempt to call global ‘LocalPlayer’ (a nil value)

Here’s my Code: [lua]function SWEP:PrimaryAttack()

local ply = LocalPlayer()

if (!SERVER) then return end

ply:TraceHullAttack( ply:GetShootPos(),
ply:GetAimVector() * 120,
Vector( -16, -16, -16),
Vector( 36, 36, 36),

end [/lua]

Can anyone help? This is my first attempt to actually make my own SWEP.

You need to use
Not LocalPlayer().

From the PrimaryAttack() function in Garry’s Example SWEP -
function SWEP:PrimaryAttack()

local tr = self.Owner:GetEyeTrace()
if ( tr.HitWorld ) then return end

local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos )
effectdata:SetNormal( tr.HitNormal )
effectdata:SetMagnitude( 8 )
effectdata:SetScale( 1 )
effectdata:SetRadius( 16 )
util.Effect( "Sparks", effectdata )

self.Weapon:EmitSound( ShootSound )
self.BaseClass.ShootEffects( self )

// The rest is only done on the server
if ( !SERVER ) then return end

// Make a manhack
local ent = ents.Create( "npc_manhack" )
ent:SetPos( tr.HitPos + self.Owner:GetAimVector() * -16 )
ent:SetAngles( tr.HitNormal:Angle() )

// Weld it to the object that we hit
local weld = constraint.Weld( tr.Entity, ent, tr.PhysicsBone, 0, 0 )

undo.Create( "Manhack" )
undo.AddEntity( weld )
undo.AddEntity( ent )
undo.SetPlayer( self.Owner )