Saving CFrame angle of a part

So, I am making a building game where each environment saves but when I load in parts, some angles are the wrong way.

Also, I need to be able to save the angles in as few values as possible (CFrame:GetComponents() is a last resort) because I am making a model builder plugin where people can build things in studio to bring it in-game but Script.Source has a character limit of 250k.

Here’s some code that I used to try and troubleshoot my issue because I thought that it would produce the same angle (It doesn’t for some parts. File linked below):

Place1.rbxl (55.2 KB)

local s = game:GetService("Selection"):Get()[1]
local x, y, z = s.CFrame:ToEulerAnglesXYZ()
s.CFrame = * CFrame.fromEulerAnglesXYZ(x, y, z)

Can someone explain why this would result in a rotation that is completely wrong for only some parts?

I recommend saving the orientation instead of the CFrame angle. This is because orientation is Vector3 making it easier to store, here is the fixed code:

local Selection = game:GetService("Selection"):Get()[1]
local Orientation = Selection.Orientation
Selection.CFrame = * CFrame.Angles(math.rad(Orientation.X), math.rad(Orientation.Y), math.rad(Orientation.Z))```
1 Like

I’m still getting the same issue but now with a different set of parts. Place file below.

place2.rbxl (64.0 KB)

I also tried to see if the issue was with using CFrame.Angles instead of CFrame.fromOrientation and I still get the same rotation issue but also with another different set of parts.

make a table of the parts and angles and set the angles

That would still result in the same issue though because the angles stay the same.

Just save the cframe no need to save rotations since the cframe already contains all the necessary data