Placement save system not working

so i have this system that saves every placeable once the server stops and reloads them when the server starts again. But for some reason the placement seems to have the wrong rotation :expressionless:

local BuildData = game:GetService("DataStoreService"):GetDataStore("PlayerPositionData")
function decode_cframe(cf)
    local yes = string.split(cf, " ")
    print(yes)
    return CFrame.new(Vector3.new(yes[1], yes[2], yes[3]), Vector3.new(yes[4], yes[5], yes[6]))
end
function loaddata(table)
    local info
    pcall(function()
        info = BuildData:GetAsync("server")
    end)
    print(info)
    if info then
        for i =1 , #info do
            local str = info[i]
            local split = str:split(':')
            local pos = split[1] 
            local name = split[2]
            print(name)
            local folder = game.ReplicatedStorage:FindFirstChild(name)
            local posc = decode_cframe(pos)
            local place = folder:FindFirstChild(name)
            local clone = place:Clone()
            clone.Parent = game.Workspace
            clone:SetPrimaryPartCFrame(posc)
            print(clone.PrimaryPart.CFrame)
            print(posc)
        end
    else
        
    end
end
wait(5)
loaddata()
game:BindToClose(function()
    print("closing")
    local builds = {}
    for i,v in pairs(game.Workspace.Placements:GetChildren()) do
        local name = v.Name
        local pos = v.PrimaryPart.CFrame
        local posc = string.format(string.rep("%f ",12), pos:components())
        local save = posc .. ":" .. name
        table.insert(builds, save)
    end
    print(builds)
    BuildData:SetAsync("server", builds)
end)

^^save and load script
vid = https://streamable.com/rrl8uk

Perhaps you need to save the orientation as well as the position.

As @RamJoT has mentioned. You need to save the orientation.

This can be done by saving and setting the CFrame rather than position or by saving the orientation as well.

Oh right i figured it out i put the wrong CFrame values in :expressionless:

1 Like