Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrames won't save to datastore properly?

Asked by 6 years ago
Edited 6 years ago

I have been making this sandbox type building game which includes saving and loading a base. However i have been having a problem where the C0 and C1 CFrames don't save properly in the datastore

EDIT: it is saving the C0 and C1 values

Before: https://imgur.com/a/BqtzGJj

After: https://imgur.com/a/vxWzEkJ

my code is below:

Saving:

local mTable = {} -- snipet of code
    for i,v in pairs(t) do
        if workspace.Place:FindFirstChild(v.Name) then
            local Table = {}
            game:GetService("RunService").Heartbeat:Wait()
            Table.Name = v.Name
            Table.C0 = {v.PrimaryPart.PlotWeld.C0:components()}
            Table.C1 = {v.PrimaryPart.PlotWeld.C1:components()}
            print(unpack(Table.C1))
            v:Destroy()
            table.insert(mTable, Table)
        else
            warn("Instance "..tostring(v).." Couldn't Be Found")
        end
    end
    mTable = game.HttpService:JSONEncode(mTable)
    save:SetAsync(plr.UserId, mTable)
    print("Save Success")

Loading:

print("Fetching Save")
    local mSave = save:GetAsync(plr.UserId) or nil
    if mSave then
        local sTable = game.HttpService:JSONDecode(mSave)
        print("Save Fetched: Estimated Size = "..math.floor(string.len(mSave)).."\nLoading")
        for i,v in pairs(sTable) do
            game:GetService("RunService").Heartbeat:Wait()
            if workspace.Place:FindFirstChild(v.Name) then
                print("Found "..v.Name.." Loading Object")
                local obj = workspace.Place[v.Name]:Clone()
                obj.Parent = plr.PlotOwned.Value.Drawing
                local weld = Instance.new("Motor6D", obj.PrimaryPart)
                weld.Name = "PlotWeld"
                weld.C0 = CFrame.new(unpack(v.C0))
                weld.C1 = CFrame.new(unpack(v.C1))
                weld.Part0 = obj.PrimaryPart
                weld.Part1 = plr.PlotOwned.Value.TP
                print("Made Welds And Placed Object Successfully!")
            end
        end
    else
        print("No Data Saved!")
0
Solves by owner. the8bitdude11 358 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Solved by the owner.

Ad

Answer this question