Issue with saving & loading Tables within DataStores

Hello! For the past few days, I was looking for a more convenient way to create an inventory system, but I’ve had a constant issue of data not being able to be registered properly.

Here is my DataStore saving script.

function SaveData(Player)

	local inventory = {}

	for i, value in pairs(Player.Items:GetChildren()) do

		table.insert(inventory,value.Name)
		inventory[value.Name] = {
			Amount = value.Value,
			Name = value.Name
		}
		print(inventory[value.Name]["Amount"].." "..inventory[value.Name]["Name"])
		
	end
	Data:SetAsync(Player.UserId, inventory)


end

Here is how the Data ends up being loaded.

			local IData= Data:GetAsync(player.UserId) or {}
			

			for ITag, ICountin pairs(IData) do

				invFolder[ITag].Value = ICount["Amount"]
				print(ITag..","..ICount["Amount"])
				
			end

I have no clue why this isn’t loading the values correctly, & I’d appreciate some assistance. Thank you in advance.

1 Like