How to correctly parent shit to attachment points?

[lua]
function CreateHeadOnSpawn( ply )
local prev_head = ply:GetNWEntity( “head” )

local eyeAttachID = ply:LookupAttachment( "eyes" )
local eyeAngPos = ply:GetAttachment( eyeAttachID )
local eyeAng = ( eyeAngPos.Ang:Right() * -1 ):Angle()
local eyePos = eyeAngPos.Pos - eyeAng:Up()*25 - eyeAng:Forward()*6

if ply:GetNWEntity("phys_head"):IsValid() then
	ply:GetNWEntity("phys_head"):Remove()
end

if prev_head:IsValid() then
	if prev_head:GetParent() != ply then
		prev_head:SetParent( ply )
		prev_head:SetPos( eyePos )
		prev_head:SetAngles( eyeAng )
		prev_head:Fire( "SetParentAttachmentMaintainOffset", "eyes", 0.01 )
	end
else
	local head = ents.Create( "prop_dynamic" )
	head:SetModel( "models/Gibs/antlion_worker_gibs_head.mdl" )
	head:Spawn()
	
	head:SetParent( ply )
	
	head:SetPos( eyePos )
	head:SetAngles( eyeAng )
	
	head:Fire( "SetParentAttachmentMaintainOffset", "eyes", 0.01 )
	
	head:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
	
	ply:SetNWEntity( "head", head )
end

end
hook.Add( “PlayerSpawn”, “CreateHeadOnSpawn”, CreateHeadOnSpawn )

function GetPlayerHeadPosAndVelocityOnDeath( prey, pred, dinfo )
local head = prey:GetNWEntity( “head” )

if head:IsValid() then
	prey:SetNWVector( "death_head_pos", head:GetPos() )
	prey:SetNWVector( "death_head_ang", head:GetAngles() )
end

prey:SetNWVector( "death_vel", prey:GetPhysicsObject():GetVelocity() )

end
hook.Add( “DoPlayerDeath”, “GetPlayerHeadPosAndVelocityOnDeath”, GetPlayerHeadPosAndVelocityOnDeath )

function DetachHeadFromRagdollOnDeath( prey, pred, dinfo )
local head = prey:GetNWEntity( “head” )
local headPos = prey:GetNWVector( “death_head_pos” )
local headAng = prey:GetNWVector( “death_head_ang” )

if head:IsValid() then
	head:Remove()
	
	local phys_head = ents.Create("prop_physics")
	phys_head:SetModel( "models/Gibs/antlion_worker_gibs_head.mdl" )
	phys_head:Spawn()
	
	if headAng != nil then
		phys_head:SetAngles( headAng )
	end
	
	if headPos != nil then
		phys_head:SetPos( headPos )
	else
		phys_head:SetPos( prey:GetPos() + Vector(0,0,32) )
	end
	
	phys_head:SetMoveType( MOVETYPE_VPHYSICS )
	phys_head:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
	
	local preyDeathVel = prey:GetNWVector( "death_vel" )
	if preyDeathVel != nil then
		phys_head:GetPhysicsObject():SetVelocity( preyDeathVel )
	end
	
	prey:SetNWEntity( "phys_head", phys_head )
end

end
hook.Add( “PlayerDeath”, “DetachHeadFromRagdollOnDeath”, DetachHeadFromRagdollOnDeath )
[/lua]

I’m trying to make it so that all players get antlion worker heads. To do that, I know you have to parent it to the head’s attachment point. To do that, you have to parent it to the player, then fire the input SetParentAttachmentMaintainOffset. However, for some reason which I can’t seem to understand, when I parent the antlion head to the player the position gets fucked up. It’s different every time! No matter what order I put SetPos and SetParent in, it still gets fucked up. I even tried using a timer to delay the parenting, but still no dice. It’s really, really frustrating not to be able to do something this mundane. Does anyone have any ideas? I know that expression 2 has the same problem when trying to parent holograms to player’s heads. Is it just not possible to make code that parents things to attachment points reliably?

Sorry to bump, but this is relatively important. I mean, my gamemode is called “Ants” anyway…I want them to look like ants. Or, at least their heads…

:love::goatse::love:

bump. I have the exact same problem

bump, same I need the answer to this!!!