Hello in my DataStore script i’m going through a player folder in ServerStorage which has the names of things i want to save then i check the same folders and what’s inside them on the player and save them. However for the inventory i’m doing it differently as i create a inventory sub folder which contains the value and attributes of my swords.
players.PlayerRemoving:Connect(function(player)
if loaded[player]==nil then return end
local data = {}
for i,folder in game.ServerStorage.PlayerFolder:GetChildren() do
local subfolder = {}
local inventorysub = {}
if folder.Name == "Inventory" then
for i, sword in player["Inventory"]:GetChildren()do
inventorysub[i] = {}
inventorysub[i]["Value"] = sword.Value
local swordAttributes = sword:GetAttributes()
for name, value in pairs(swordAttributes) do
inventorysub[i][name] = value
end
end
data["Inventory"]= inventorysub
print(inventorysub)
else
for i, child in player[folder.Name]:GetChildren() do
subfolder[child.Name] = child.Value
end
data[folder.Name] = subfolder
end
end
local success, errorMessage = pcall(function()
print("saved")
PIS:SetAsync(player.UserId,data)
end)
loaded[player] = nil
end)
Anything other than inventory saves perfectly (i check it with the DataStore editor plugin)
I have no idea why the inventory doesn’t save since print(inventorysub)
prints things correctly and exactly as they should be so where could the issue be?
Thanks in advance for any help.