#Datastore help

1 messages · Page 1 of 1 (latest)

tired dust
#

I am printing what im adding before the datastore, and after.
My before print is what i want it to look like, but my after (line 41) just shows the surface level of the table

#

function PlayerSave(Player)
    local DataStore = game:GetService("DataStoreService")
    local PlayersData = DataStore:GetDataStore("Players_"..game.ServerStorage.WorldID.Value)
    local HttpService = game:GetService("HttpService")
    local backpack = game.ReplicatedStorage.Backpacks[Player.Name]
    -- Save Backpack
    local addeddata = {
        Backpack = {},
        Stats = {},
        
        
    }
    for i,v in pairs(backpack:GetChildren()) do
        if not v:HasTag("NonLinearTool") then
            table.insert(addeddata.Backpack,v.Name)
            addeddata.Backpack[v.Name] = v:GetAttribute("Amount") or 1
        end
        if v:HasTag("NonLinearTool") then
            if v:FindFirstChild("EncodedString") then
                table.insert(addeddata.Backpack,v:FindFirstChild("EncodedString").Value)
            end
        end
    end
    -- Actually save the added data
    local data = HttpService:JSONEncode(addeddata)
    PlayersData:SetAsync(Player.UserId, data)
    print(addeddata)
    print(HttpService:JSONDecode(data))
end```
#

yeah nvm it works now