Setting the position of an entities parent.

I’m a bit new to lua and I’m working on something that holds gun, basically when the gun touches the entity it sets it parent to the gun holder, its pretty simple.
What I need to know how to do is set the position of the gun when it hits the holder, I’ve tried setting it’s position to the holders position plus the vector but it does not seem to work, it just goes somewhere in the map.
I was wondering what I am doing wrong, any help would be much appreciated :).

ent:SetPos( holder:LocalToWorld( Vector( 0, 0, 0 ) )

Still the same thing, it just goes somewhere random in the world.
Not random just somewhere I can not find it.

well try Entity( 1 ):SetPos( ent:GetPos() ) after and see where it goes, possibly you use bad values in vector?

Same thing,
My original code:


function ENT:Touch( hitEnt ) 
	local x = self:GetPos()
	if hitEnt:GetClass()== "spawned_weapon" then
	hitEnt:SetParent(self)
	hitEnt:SetParentPhysNum(1)
	hitEnt:SetPos(x + Vector(0, 0, 50))
	end
end


function ENT:Touch( hitEnt ) 
	local x = self:GetPos()
	if hitEnt:GetClass()== "spawned_weapon" then
	hitEnt:SetParent(self)
	hitEnt:SetParentPhysNum(1)
	hitEnt:SetPos(x + Vector(0, 0, 50))
        Entity( 1 ):SetPos( hitEnt:GetPos() );     
        print( tostring( hitEnt:GetPos() );
        print( tostring( self:GetPos() );
        
	end
end


not sure how the SetParentPhysNum works but maybe try with LookupBone, FollowBone?

Thank you for this, this helps me a bit better with the vector much appreciated!