Parenting to player ( HELP ME )

Hey so I’m trying to parent an entity to the players back, but i can’t get it to position correctly, it seems each time I run the function, the entity I am parenting ends up in a slightly different place, If anybody could provide any sort of help, I would very much appreciate it.

Here is the function I am using:

function meta:Parent_Ent( ent,attachment,vec,ang )
	ent:SetCollisionGroup( COLLISION_GROUP_WORLD ) 
	local aindex = self:LookupAttachment( attachment )
	local atable = self:GetAttachment( aindex )
	local f = self:GetAimVector():Angle()
	f.p = 0
	f.r = 0
	ent:SetPos( atable.Pos + ( -f:Forward() * 10 ) ) 
	ent:SetAngles( atable.Ang + ang )
	ent:SetParent( self )

	ent:Fire("setparentattachmentmaintainoffset",attachment, 0.01)

// Example of how I am using this function
ply:Parent_Ent( self,"chest",Vector( 0,0,0 ),Angle( 0,0,0 ) )

(User was banned for this post ("wrong section" - postal))

You should snip this and post it in the right section before you get forum banned.