Getting the Y orientation from a cframe

So I’m developing a plot loading system and im using :ToWorldSpace() and :ToObjectSpace() to load plots into separate locations, however, I am struggling to understand how to grab the Y rotation of a furniture item from its Primary Part CFrame while also using ObjectSpace

I have tried:

local y = cframe:ToObjectSpace(CFrame.new(v:GetPrimaryPartCFrame().p)).Rotation.Y

cframe is just the house plot and that doesn’t have anything to do with my problem

This line of code will just return 0 everytime and load in the plot with every furniture facing the same way at Y rotation 0

Use CFrame.Angles when attempting to get the Rotaion.

Would you be able to show me how to format it?

object:SetPrimaryPartCFrame(CFrame.new(position) * CFrame.Angles(0,math.rad(0),0))

I don’t want to set the rotation, I just need to get the Y orientation and save it as a variable

Try changing CFrame.new to CFrame.Angles when saving the Y.

Sorry, can you take a step back? What exactly are you trying to do?

If you’re storing the object-space CFrame of the furniture, and converting it back to world-space when you load, what’s the problem? The CFrame should contain the position and rotation info.

DataStore2 doesn’t allow me to save cframes so I have to save X, Y, Z and the rotation all separately

If you just need a way to store CFrames, you can do that:

You can optimize that if you need to by converting to a quaternion sending the smallest three components as described here in “Optimizing Orientation”. But it’s twelve numbers without that so I wouldn’t bother.

I’ve managed to do this by playing around with what I believe is CFrame:ToAxisAngle().