I am trying to save an array made up of CFrames of objects, for serialization purposes.

Cannot save arrays with DataStore

I actually don't know why it is erroring, because I'm sure I can save tables in DataStore. Maybe its just that my table is filled with CFrames?

Code used:

game.Players.PlayerAdded:connect(function(plyr)
    while true do
        wait(60)
        local build=script.Parent

        local pur=build.purchased
        local DataStore = game:GetService("DataStoreService")
        local PlayerData = DataStore:GetDataStore("PlayerData")
        local PlayerD
        local pnumb=#pur:GetChildren()
        local purs=pur:GetChildren()
        local cframes={}
        local number=0
        for i=1, pnumb do
            number=number+1
            local item=purs[number]
            local cframe=item.PrimaryPart.CFrame
            table.insert(cframes,number,cframe)
            print(item.Name)
            print(cframes[number])
        end
        PlayerData:SetAsync(("CFRAMES".. plyr.UserId),cframes)
    end
end)

2 comments

0

try saving it's x y and z. If you need the rotation of the part, use the rotation property, and it's x y and z.

0

what? isn't that cframe?