Geting an entity, and moving it in a swep

I have this swep code, and i get no errors, it just does absolutely nothing.
Can someone tell me why it does absolutely nothing?

[lua]
if (SERVER) then --the init.lua stuff goes in here

AddCSLuaFile (“shared.lua”);

SWEP.Weight = 5;
SWEP.AutoSwitchTo = false;
SWEP.AutoSwitchFrom = false;

end

if (CLIENT) then --the cl_init.lua stuff goes in here

SWEP.PrintName = “Chair throwing gun”;
SWEP.Slot = 3;
SWEP.SlotPos = 1;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;

end

SWEP.Author = “Sam Douglas”;
SWEP.Contact = “sam.douglas32@gmail.com”;
SWEP.Purpose = “Assists in throwing chairs”;
SWEP.Instructions = “Left click to throw an office chair; right click to throw a wooden chair”;
SWEP.Category = “Prop Launchers”

SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;

SWEP.ViewModel = “models/weapons/v_pistol.mdl”;
SWEP.WorldModel = “models/weapons/w_pistol.mdl”;

SWEP.Primary.ClipSize = -1;
SWEP.Primary.DefaultClip = -1;
SWEP.Primary.Automatic = true;
SWEP.Primary.Ammo = “none”;

SWEP.Secondary.ClipSize = -1;
SWEP.Secondary.DefaultClip = -1;
SWEP.Secondary.Automatic = false;
SWEP.Secondary.Ammo = “none”;
local ShootSound = Sound (“Metal.SawbladeStick”)
function SWEP:Reload()
end

function SWEP:Think()
end
function SWEP:SecondaryAttack()
SPos = self.Owner:GetShootPos()
AImvec = self.Owner:GetAimVector()
tracetable = {}
tracetable.start = SPos
tracetable.endpos = AImvec+(AImvec*80)
tracetable.filter = self.Owner
tracer = util.TraceLine(tracetable)
entity = tracer.Entity

end
function SWEP:PrimaryAttack()

if (entity:IsValid() && !entity:IsWeapon() && !entity:IsWorld()) then

		entity:GetPhysicsObject().SetVelocity( tracer.HitPos*1000 )

end
end

[/lua]
All in shared.lua

The variables “trcer” and “entity” might be limiting themselves to just the secondary attack function even though it’s not a local variable. Also, I think setting the velocity of a physics object MIGHT only work on a prop, but I’m not sure.

You mean tracer, not trcer, and im using it on a prop. How can i make them actually global?

[editline]04:14PM[/editline]

Seeing as there is no global <variable> command…
[lua]
global test
[/lua]

Not specifying ‘local’ will make the variable global. You need to call SetVelocity as a method - using ‘:’ instead if ‘.’.

Hi, I am Andres Kramack from http://www.cathybarryadultstore.com/.

It’s a ‘pleasure’ serving the public if you know what I mean.

Here at Cathy Barry Adult Store, we offer a wide variety of dildos that come in all sizes from goblin-sized dicks to black-man draconic dicks. I know at Facepunch everyone loves good old dicks which is why I personally offer anyone with an association with Facepunch Forums a 50% discount code “DIL4FACEPUNCH”. Don’t forget, this offer lasts until the next Garry’s Mod update which we so much love.

Here are pictures of our products just for you!

https://pbs.twimg.com/media/BKX0mMJCAAAnUji.jpg

Our wonderful sponsors:

Rubat approved: