[HELP] Attach Model To Playermodels Head What is Happening with my Angles

Here is a video with my problem

If it is not obvious the problem I have is when I look upwards the model completley flips.
I’m trying to make a mask addon for my gmod server and make it so you can buy mask from a store.



local hats = { }

local function CreateHat( pl, model )
	SafeRemoveEntity( pl.Hat )

	local hat

	hat = ClientsideModel( model, RENDERGROUP_OPAQUE )
	hat:SetNoDraw( true )

	pl.Hat = hat
	hat.Owner = pl
	table.insert( hats, hat )
end

local function CleanHats( )
	local k, v

	for k, v in pairs( hats ) do
		if not IsValid( v ) then
			hats[ k ] = nil
		elseif not IsValid( v.Owner ) then
			SafeRemoveEntity( v )
			hats[ k ] = nil
		end
	end
end

local function DrawHats( )
	local k, v, pos, ang

	CleanHats( )

	for k, v in ipairs( player.GetAll( ) ) do
		if not v:Alive( ) and IsValid( v.Hat ) then
			SafeRemoveEntity( v.Hat )
			v = v:GetRagdollEntity( )
		end

		if not IsValid( v.Hat ) then
			CreateHat( v, "models/horsie/horsiemask.mdl" )
		end

		pos, ang = v:GetBonePosition( 6 )
		
		v.Hat:SetPos( pos )
		v.Hat:SetAngles( ang + Angle(60,100,-150))
		v.Hat:DrawModel( )
	end
end

hook.Add( "PostDrawOpaqueRenderables", "Draw Hats.PostDrawOpaqueRenderables", DrawHats )


Try using Angle:RotateAroundAxis() instead of adding angles together.

[editline]1st February 2016[/editline]

And [del]

Entity:SendViewModelMatchingSequence[/del]

[editline]penis[/editline]
Lmao, wrong link. This instead:

Entity:SetParentPhysNum

I’d suggest you use SetParent( player, player:LookupAttachment(“name”) ) and then SetLocalPos and SetLocalAngles instead of whatever you are using currently.

Attachment IDs are not guaranteed to be the same across all players, attachment names are.

Can you please show me how to implement these into my code I’m not quite sure where to change any of this