How would you go about saving + loading a models position and orientation?

Basically, in my game I have an open world terrain based plot where you can freely build structures of any orientation and position, im wondering how I could save and loading the position + orientation of the model in the most compact way possible,

Any ideas?

1 Like

Have a PrimaryPart of the model, save the PrimaryPart’s X, Y and Z of the Position in an array and the PrimaryPart’s X, Y and Z of the Orientation in an array. It’d look something like:

local pos = PrimaryPart.Position
local rot = PrimaryPart.Rotation
local data = {Position = {pos.X, pos.Y, pos.Z}, Orientation = {rot.X, rot.Y, rot.Z}}

And in terms of loading?

Would I just do :SetPrimaryPartCframe()
30 char

1 Like

Lets say data is the received data:

PrimaryPart.Position = Vector3.new(unpack(data.Position))
PrimaryPart.Orientation = Vector3.new(unpack(data.Orientation))

OR

PrimaryPart.CFrame = CFrame.new(unpack(data.Position)) * CFrame.Angles(unpack(data.Orientation))
2 Likes