So I had been debugging for just 5 Minutes and I can’t seem to fix it on my own, ill provide anything if possible!
Output
16:25:09.955 - ServerStorage.Aero.Services.GameStats.Stats:281: invalid argument #1 to 'insert' (table expected, got nil)
16:25:09.956 - Stack Begin
16:25:09.958 - Script 'ServerStorage.Aero.Services.GameStats.Stats', Line 281 - function PlayerRemoved
16:25:09.969 - Stack End
Code
-- for Inventory Saving or as Item Saving
for Name, Items in pairs(Backpack:GetChildren()) do
-- check if the ItemName was snot in the table before
if PlayerData.Inventory[tostring(Items.Name)] then table.insert(PlayerData.Inventory, Items.Name) end
for _, Objects in pairs(Items:GetChildren()) do
if Objects:IsA("Folder") and Objects.Name == "Values" then
for ValueNames, Values in pairs(Objects:GetChildren()) do
table.insert(PlayerData.Inventory[tostring(Items.Name)], Values.Name)
print(ValueNames)
PlayerData.Inventory[tostring(Objects.Parent.Name)][Values.Name] = Values.Value
print("inserted")
end
end
end
end
the only debugging, I actually did was access my old code but I can’t access it anymore and the other debugging was simply searching topics with the same problem as me but no one had a piece of code similar to mine in topics so that’s why I need help thanks!
So table.insert() expects a table. You are providing an index of the table ‘Inventory’. If the value of the index is not a table, then the code will error. Make sure you are providing a table and not a table index whos value is not another table.
17:10:11.573 - ServerStorage.Aero.Services.GameStats.Stats:282: attempt to index nil with 'ChanceToGet'
17:10:11.576 - Stack Begin
17:10:11.578 - Script 'ServerStorage.Aero.Services.GameStats.Stats', Line 282 - function PlayerRemoved
17:10:11.580 - Stack End