This is my first post on the Developer Forums, hopefully I explain it well enough for you.
What is the best method for adjusting a CFrame so it loads at the right point.
This example will help you understand what I’m trying to accomplish.
John joins my game and the server places him on base one.
He places 5 items on his base and leaves the game with his data saved.
John decides to join my game again the next day and the server places him on base four.
All his items load in, but their CFrames cause them to be positioned at base one.
You should save the position relative to the base instead of relative to the world origin.
For example, if each base is a model with a PrimaryPart set in a consistent way, then you could write:
local cframeToSave = baseModel.PrimaryPart.CFrame:Inverse() * itemObject.CFrame
-- later, after retrieving from data store
local cframeToSet = baseModel.PrimaryPart.CFrame * cframeFromDataStore
Edit: My original code was incorrect because I had the left and right sides of the multiply flipped around. It should work now.
You can save its CFrame, put it in a model with a PrimaryPart, then position it like normal. When done use SetPrimaryPartCFrame() to move it to the right spot.
local X = Base.PrimaryPart.CFrame.X - Item.PrimaryPart.CFrame.X
local Z = Base.PrimaryPart.CFrame.Z - Item.PrimaryPart.CFrame.Z
local ItemData = {ItemName,X,Z}
It seems to work in Solo but not in regular game with more than one player (2-4). There are no errors, everything gets replicated, but the CFrame is wrong.
Using @Tiffblocks method because it looks cleaner. (Accidentally replied to myself, was trying to reply to you.)