game.Players.PlayerRemoving:Connect(function(plr)
print("running removing")
local priorData = dataStore:GetAsync(plr.UserId)
print('loaded old data')
local dataToSave = {
['gagueStats'] = {
['gglvl'] = plr.gg.Value,
['ggxp'] = plr.ggEXP.Value,
['tp'] = plr.tp.Value,
['str'] = plr.str.Value,
['strxp'] = plr.strEXP.Value,
['int'] = plr.int.Value,
['intxp'] = plr.intEXP.Value,
['end'] = plr['end'].Value,
['ednxp'] = plr.endEXP.Value,
['dex'] = plr.dex.Value,
['dexxp'] = plr.dexEXP.Value
},
['appearanceStats'] = priorData['appearanceStats'],
['spiderwebCompletion'] = priorData['spiderwebCompletion'],
['inventory'] = {
},
['gold'] = plr.gold.Value
}
print('table created')
for i,v in pairs(plr.inv:GetChildren()) do
print(v)
table.insert(dataToSave['inventory'], i, v.Name)
end
print('inv stuff added')
dataStore:SetAsync(plr.UserId, dataToSave)
print('saved')
end)
The goal is to take everything inside a folder named "inv" inside the player and save it under the inventory table in the data table, however, when I load back into the game there are no items in my inventory except for one copy of trash when there should be two (I have a script to add it to my inventory every time I load in)
When I tried print debugging, it only printed down to "running removing" which is the first print. Why would nothing after this run? There are no errors for it either.

5 comments
I've also tried testing this outside of studio, and it still didn't work
Update, it says attempted to index nil with GetAsync ingame when my friend left. Any ideas?
Try removing the i, part after ['inventory;] and before v
Didn't seem to work
You haven't declared dataStore, add a line at the top of the code saying "local dataStore = game:GetService("DataStoreService"). I'm sorry if this didn't help, haven't scripted in months :D