Getting an entity to stick to walls, props and bones

Ello there, I dont really know much coding but I was wondering how to get some code to work to get an entity to weld itself to ragdoll and npc bones, the world and props.
Ive looked into http://wiki.garrysmod.com/page/constraint/Weld
https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcdb2.html
http://wiki.garrysmod.com/page/Chair_Throwing_Gun

Ive had so many results but the closest I got was having it stick to walls… and found some code where it would stick to props and stay in the prop perfectly, cant say the same for ragdolls, it hits the exact postion of the bone but it just sits in the air, doesnt rotate, it rather parents the base bone it seems and stays with the ragdoll but not attached to a bone sadly…

And Ive stuck together lots of code and got help from someone but not even he could get it right but he was sure it would work.
Here’s the code I found



function ENT:PhysicsCollide( data, phys )
	
	if self:GetVelocity():Length() < 250 then
		self:Disable()
		return
	end
	local Ent = data.HitEntity
	if !(ValidEntity( Ent ) || Ent:IsWorld()) then return end
	if Ent:IsWorld() then
		if data.OurOldVelocity:Normalize():Dot( data.HitNormal ) > .5 then
			self:SetPos( data.HitPos )
			self:SetAngles( data.OurOldVelocity:Angle() )
			self:GetPhysicsObject():EnableMotion( false )
			util.Decal( "ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal )
			self:EmitSound( self.Hit[math.random(1,#self.Hit)] );
		end
		self:Disable()
	elseif Ent.Health then
		if not(Ent:IsPlayer() || Ent:IsNPC() || Ent:GetClass() == "prop_ragdoll") then 
			util.Decal( "ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal )
			self:EmitSound( self.Hit[math.random(1,#self.Hit)] );
		end
		Ent:TakeDamage( 18, self:GetOwner() )
		self:SetPos( data.HitPos )
		self:SetParent( Ent )
		Ent:DeleteOnRemove( self )
		self:Disable()
		if (Ent:IsPlayer() || Ent:IsNPC() || Ent:GetClass() == "prop_ragdoll") then 
			local effectdata = EffectData()
			effectdata:SetStart( data.HitPos )
			effectdata:SetOrigin( data.HitPos )
			effectdata:SetScale( 1 )
			util.Effect( "BloodImpact", effectdata )
			self:EmitSound( self.FleshHit[math.random(1,#self.Hit)] );
			self:Remove() --Go ahead and drop this line or comment it if you want it to stick to npcs.
		end
	end
	
end



 local weld = constraint.Weld( thruster, trace.Entity, 0, trace.PhysicsBone, 0, collision == 0, true ) 

The closest ive come with this constraint weld was:


 local weld = constraint.Weld( self, Ent:IsValid(), 0, 0, 0, collision == 0, true ) 

And so it would do weird things… Im not sure im doing anything right or Im not sure where to insert that ;7

Help would be appreciated :3

rump