Question regarding saving positional data with data storing

function Load(Player)
    repeat wait() until Player.Character
    local data = nil
    local good, info = pcall(function()
        data = dataStore:GetAsync(Player.UserId .. "_blocks")
    end)
    if good and data then 
        for _,v in pairs(bases:GetChildren()) do
            print("k going")
            if v:FindFirstChild("Owner").Value == Player.UserId then
                print("found em")
                for index, tabl in pairs(data) do
                    local PlayerBase = v:WaitForChild("Blocks")
                    print("k creating part")
                    local NewPart = Instance.new("Part")
                     NewPart.Name = "MEPART"
                    NewPart.Parent = PlayerBase
                    NewPart.Size = Vector3.new(3,3,3)
                    NewPart.Position = Vector3.new(tabl["Position"][1],tabl["Position"][2], tabl["Position"][3]) --Here
                    NewPart.Color = Color3.new(tabl["Color"][1],tabl["Color"][2], tabl["Color"][3]) 
                    print("Created")
                end
                break -- stop looping through the other bases
            end
        end
    else
        print("UNABLE TO ", info)
    end
end

So, there is a placement system and when you have placed something, and rejoined it reloads everything you have placed on your specific base. However, each time the player joins the game the base may be different, so the position can’t stay constant because then it’d be on someone else’s base. How could I make it so the part positions itself on the persons current base [rather than the saved position]? Could I do it relevant to a corner?

2 Likes

You need to calculate the offset of the parts from the origin of the base and then use that for the new base. I am sure there are posts to do with finding relative difference between two positions.

2 Likes