Settings part's CFrame changes the orientation values incorretly

Im trying to set a Block’s(Model) Rep’s(Primary Part) CFrame with a given position and orientation. The position is a table of {X,Y,Z} and the Orientation is the same with {OriX,OriY,OriZ}.

The script below sets the position perfectly, and prints out the ToEulerAngles of the orientation for debugging. EVERYTHING printed is correct, however, when Rep’s Orientation is set, its very wrong, but close.

--Create a Orientation CFrame
local orientationFrame = CFrame.fromEulerAnglesXYZ(math.rad(Block.Orientation[1]),math.rad(Block.Orientation[2]),math.rad(Block.Orientation[3]))
--local orientationFrame = CFrame.Angles(math.rad(Block.Orientation[1]),math.rad(Block.Orientation[2]),math.rad(Block.Orientation[3]))
--Print what the Orientation is supposed to be in X,Y,Z
print(P(0,"Orientation Recieved: ",unpack(Block.Orientation)))
--Convert CFrame orientation to EulerXYZ for debugging purposes
local oriX,oriY,oriZ = orientationFrame:ToEulerAnglesXYZ()
oriX,oriY,oriZ = math.deg(oriX),math.deg(oriY),math.deg(oriZ)
--Print result
--Repeat the above steps for adding the orientation CFrame to the Position CFrame
--(I figured seperating the CFrames might help with debugging. It didnt)
print(P(0,"OrientationFrame to EulerAngles: ",oriX,oriY,oriZ))
local TargetCFrame =*orientationFrame
local TarX,TarY,TarZ = TargetCFrame:ToEulerAnglesXYZ()
TarX,TarY,TarZ = math.deg(TarX),math.deg(TarY),math.deg(TarZ)
print(P(0,"TargetCFrame ToEulerAngles: ",TarX,TarY,TarZ))
--Set the Rep CFrame (It looks very good at this point)
BlockClone:WaitForChild("Rep").CFrame = TargetCFrame
print("BlockRep Orientation: ",BlockClone.Rep.Orientation)
--The rep has a VERY WRONG Orientation from here)

Output log:

Things ive tried:

  • Using :PivotTo()
  • Using .CFrame = CFrame:ToWorldSpace()
  • Taking Cframe * Cframe.angles initially
  • Change CFrame.Angles to CFrame.FromEulerAngles()

CFrame will switch X and z angles around so the ToEulerAngles function switches them back.

1 Like

Makes sense, but im already using FromEulerAnglesXYZ() which should construct a CFrame with the proper XYZ in the right positions.

1 Like

Right now I can’t really answer because I don’t have access to studio sorry. Will help when I can but that might be a few hours

Terribly sorry for getting back to you so late. Any testing done with the cframes to aid my problem?