Help with CFrame

having a problem setting model CFrame based on CHaracter’s Head CFrame.
Im using this code on cmd bar:

local item_Model = workspace.Hayden_Almeida["Origin Cap"]  
local head = workspace.Hayden_Almeida.Head  
item_Model:PivotTo(CFrame.new(head.CFrame.X + 0.2, head.CFrame.Y + 0.60, head.CFrame.Z + 0.15) * CFrame.fromOrientation( 0, math.rad( head.Orientation.Y),  0)) 

then welding it…
When Character is looking to somewhere the Hat is fine
https://i.imgur.com/13Q13Q9.png

but when i execute the code again (nothing changed) but looking to other position:
https://i.imgur.com/UtG01yY.png

as you can see the Hat is so much off position.
The problem is the " + 0.20" in the X axis and " 0.15" in the Z axis.

Solution was use the CFrame Function: PointToWorldSpace →

local item_Model = workspace.Hayden_Almeida["Origin Cap"]  
local head = workspace.Hayden_Almeida.Head 

local OffSet = Vector3.new(0.2, 0.60, 0.15) -- change position here
local WorldOffSet = head.CFrame:PointToWorldSpace(OffSet)

item_Model:PivotTo(CFrame.new(WorldOffSet) * CFrame.fromOrientation( 0, math.rad( ParteDoCorpo.Orientation.Y),  0)) 

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.