Orientation Being Wack

Hello.

In my game, players can place down structures and they get saved by the game via the datastore service. Unfortunately, I just can’t figure out how to get the right combination of math to get it to be the same orientation no matter what plot they choose.

Here is the code for saving the orientation of the items:

player.PlayerData.Spots[spot.itemStats.itemSpot.Value].YRotation.Value = spot.Model.baseplate.Orientation.Y + (TTClaim.Orientation.Y - 180)
-- TTClaim is the claim part at the front of every plot. It has a different orientation for each plot.
-- The part I can't get right is "(TTClaim.Orientation.Y - 180)"

And here is the code I use for loading the saved orientation:

placedStructure:PivotTo(test * CFrame.Angles(0, math.rad(spot.YRotation.Value + (TTClaim.Orientation.Y - 180)), 0))
-- Test is the CFrame for the model but only x, y, and z as I convert it to vector3 and back to remove all other unnecessary CFrame values
-- You can see the same math being used here

This works for plots two and four, but the orientation gets mixed up when I try going in one and three.
The plots:
image
Does anyone know how I can fix this?

Thanks,
– Ham

Use CFrame instead of orientation. With this, you can use math to position objects relative to each of these 4 bases.

-- Tycoon.Base is the green platform, and is the PrimaryPart
local yoff = Object.Size.Y/2 + Tycoon.Base.Size.Y/2
local offsetx, offsetz -- determined by grid placement system
Object.CFrame = Tycoon:GetPivot() * CFrame.new(offsetx,yoff,offsetz)

The rotation and position you save should be relative to the tycoon, and not the world, so it can look the same at any of the tycoons.