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:
Does anyone know how I can fix this?
Thanks,
– Ham