Fix my Tazer SWEP Please

Ok, so i’ve started off on an swep that im currently working on to create a flechette as a prop and send it towards a player. When it hits the player i want it to weld to the player & then ragdoll them, and unragdoll them after 5 seconds. Please use what i have currently.
no i do not want the tazer that is on garrysmod.org
Here is my code atm:



AddCSLuaFile( "shared.lua" )

SWEP.Author			= ""
SWEP.Instructions	= "Left click to taze, Right click to untaze."

SWEP.Spawnable			= false
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		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

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

SWEP.PrintName			= "Tazer"			
SWEP.Slot				= 1
SWEP.SlotPos			= 2
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= true


local ShootSound = Sound( "NPC_Hunter.FlechetteShoot" )

function SWEP:PrimaryAttack()

	self.Weapon:SetNextPrimaryFire( CurTime() + 1 )

	self:EmitSound( ShootSound )
	self:ShootEffects( self )
	
	if (!SERVER) then return end
	
	local Forward = self.Owner:EyeAngles():Forward()
	
	local ent = ents.Create( "prop_physics" )
		ent:SetModel("models/weapons/hunter_flechette.mdl")
		ent:SetPos( self.Owner:GetShootPos() + Forward * 32 )
		ent:SetAngles( self.Owner:EyeAngles() )
		ent:Spawn()
	
	if ent:GetPos():Distance(self.Owner:GetEyeTrace().Entity:GetPos())<50 then
	tasePerson(self.Owner:GetEyeTrace().Entity)
	end
		
		ent:SetVelocity( Forward * 2000 )
		local trail = util.SpriteTrail(ent, 0, Color(255,0,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/plasma.vmt")
		trail:Spawn()
end


function SWEP:SecondaryAttack(ply)
if ply:GetEyeTrace().Entity:IsValid()
untasePerson(ply:GetEyeTrace().Entity)
end
end

function SWEP:tasePerson(ply)
	local rag = ents.Create( "prop_ragdoll" )
    if not rag:IsValid() then return end


	rag:SetModel( ply:GetModel() )
    rag:SetKeyValue( "origin", ply:GetPos().x .. " " .. ply:GetPos().y .. " " .. ply:GetPos().z )
	rag:SetAngles(ply:GetAngles())
	
	 for k, v in ipairs(ply:GetWeapons()) do
      table.insert(currentweapons,v)
	end 

	rag.taseredply = ply
	table.insert(taseredrags, rag)
		
	ply:StripWeapons()
	ply:DrawViewModel(false)
	ply:DrawWorldModel(false)
	ply:Spectate(OBS_MODE_CHASE)
	ply:SpectateEntity(rag)
	
    rag:Spawn()
    rag:Activate()

	rag:GetPhysicsObject():SetVelocity(4*ply:GetVelocity())
end

function SWEP:untasePerson(ply)
ply:UnSpectate()
ply:DrawViewModel(true)
ply:DrawWorldModel(true)
for k,v in ipairs(currentweapons) do
ply:Give(v)
end
end


Done.

Thanks bro <3. It’s people like you that secretly keep shit going.