Hello,
I’m working on a DataStore which can save builds / furniture. My method is to save:
- Model Name.
- X, Y, Z of Primary Part
- Rotation of primary part.
X, Y, Z is easy to fetch, but for rotation I do this:
-- This is the only axis rotation can be done on.
local Rotation = CFrame.Angles(0, 0, 0) -- At start of placement session.
-- Rotation *= CFrame.Angles(0, math.rad(90), 0) -- On each rotation step.
local _, y = Rotation:ToOrientation()
Then I reapply like this:
local newModelCFrame = Kellogs.KellogToCFrame(v.CFrame) -- Forms a CFrame from an X,Y,Z (Basically, there's more to it)
local newModelRotation = v.Rotation.Value -- The previously saved "y" from above extract.
newModelCFrame *= CFrame.Angles(0, newModelRotation, 0)
newModel:SetPrimaryPartCFrame(newModelCFrame)
The models always end up crooked / askew, which looks weird when the models rotate at 90 degrees intervals.
Am I doing something wrong / missing something?