Model orientation is not saving correctly

I save the models primary part orientation, then when loaded I make the rotation of the pivot of the model to the saved primary parts orientation.

This will save anchored models too so I can’t just do primary part CFrame.


Before saving

image

After loading

image

Saving code

local orient = v.PrimaryPart.Orientation
-- o in the table is orientation
SaveTable.pts[i] = {n = v.ItemName.Value, p = {offset.X, offset.Y, offset.Z}, o = {orient.X, orient.Y, orient.Z}}

Loading code

local Model = ObjectSpawnerModule.SpawnObject(ReplicatedStorage:WaitForChild("ObjectInformation"):WaitForChild(v.n))
-- o in the table is orientation

-- where the orientation is incorrect
local Rotation = CFrame.fromEulerAnglesXYZ( math.rad(v.o[1]), math.rad(v.o[2]), math.rad(v.o[3]) )
					
Model:PivotTo(Plot.PrimaryPart.CFrame*CFrame.new(v.p[1], v.p[2], v.p[3])*Rotation)

[1] = part

o = orientation table
image

solutions tried

using CFrame.YXZ
before:


after

ok found solution for some reason doing YXZ and not XYZ in CFrame works

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