Attachment added to Torso has completely incorrect CFrame orientation

After adding an attachment to the Torso of a character, the orientation of the attachment is completely incorrect.

The code that does this looks like this:

local BackAttachment = Instance.new("Attachment")
BackAttachment.Parent = Character.Torso
BackAttachment.CFrame = CFrame.new(0.213, 0.548, 1.356)
	* CFrame.Angles(math.rad(-65), math.rad(160), math.rad(120))
BackAttachment.Name = "TorsoFloatForceAtt"

image
(Attachment CFrame as seen in properties in-game)
Note how the position property is perfectly fine.

It’s run on CharacterAdded, though I don’t suspect that’s the issue. The attachment is not touched at all afterwards.

I tried adding task.wait(1) to see if it was some kind of repositioning error that happens when the character is moved to where it’s supposed to be - it isn’t, the bug still happens.

image
Printing BackAttachment.CFrame:ToOrientation() leads it to print only the X rotation in rads, which in degrees is 58.39, which is what showed in the Properties tab.

The code at this point looks like this:

task.wait(1)
local BackAttachment = Instance.new("Attachment")
BackAttachment.Parent = Character.Torso
BackAttachment.CFrame = CFrame.new(0.213, 0.548, 1.356)
	* CFrame.Angles(math.rad(-65), math.rad(160), math.rad(120))
	
print(`BackAttachment CFrame: {BackAttachment.CFrame}, Orientation: {BackAttachment.CFrame:ToOrientation()}`)
BackAttachment.Name = "TorsoFloatForceAtt"

Is there any kind of workaround for this, or could this be a bug?

Turns out that CFrame.Angles wasn’t the correct function to use in this case - after using CFrame.fromEulerAnglesYXZ, the CFrame is set perfectly fine.
image

In that case, could someone help me understand why CFrame.Angles (or CFrame.fromEulerAnglesXYZ) differs from CFrame.fromEulerAnglesYXZ? In the past, I’ve always used CFrame.Angles for attachments, and it worked fine, so what happened?

1 Like

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