Attempt to index nil with 'Pic'

Hello, I keep getting an error saying attempt to index nil with ‘Pic’. Im not sure what is wrong.
normal script:

local function GetInventory(player)
	local inv = {}
	
	for i, v in pairs(game.ServerStorage:WaitForChild("Inventory"):WaitForChild(player.Name):WaitForChild("Data"):WaitForChild("Items"):GetChildren()) do
		if v:IsA("StringValue") then
			local vprop = {i,v.Name,v.Amount.Value}
			table.insert(inv,vprop)
		end
	end

	return inv
end

game.ReplicatedStorage:WaitForChild("GetInv").OnServerInvoke = function(player)
	local inventoryInfo = {
		inv = GetInventory(player),
	}
	return inventoryInfo
end

local script:

local InvDebouce = false
sendinv.OnClientEvent:Connect(function()
	if InvDebouce == false then
		InvDebouce = true
		local Inventory = Invent:InvokeServer()
		for pos,val in next,Inventory.inv do
			local content = slotFolder:FindFirstChild("Slot"..tostring(pos))
			if Inventory.inv[pos][3] == 1 then
				content.ItemName.Text = Inventory.inv[pos][2]
			else
				content.ItemName.Text = Inventory.inv[pos][2].." x"..Inventory.inv[pos][3]
			end
			content.ItemAmount.Text = "x"..Inventory.inv[pos][3]
			content.Img.ImageTransparency = 0
			content.Img.Image = "rbxassetid://"..itemModule[Inventory.inv[pos][2]]["Pic"]
		end
		InvDebouce = false
	end
end)

I have a module script which has items in it and pic is a variable of the item and contains the ID for the image.

Maybe you should use val instead: val[2]
Also it doesn’t explain what itemModule consists of, what that table is like.

Here is my itemModule layout:

local module = {
[“Sword”] = {
Name = “Sword”,
Amount = 1,
Desc = “sword!”,
Type = “Tool”,
Selling_price = 10,
Pic = 1490529231,
drop = true,
};
}

return module

Replace these bits to val instead, it’s easier to read it. Try to check if itemModule[val[2]] actually exists. Run some standard debugging methods.

On this line you aren’t checking if the item is in the itemModule at all, which might be causing the error since you might be trying to get Pic from nothing. I’d change it to:

local itemTable = itemModule[Inventory.inv[pos][2]]
if itemTable then
    content.Img.Image = "rbxassetid://".. itemTable["Pic"]
end

Btw Pic doesn’t exist inside the sword item, the closest would be Image (Which you would have to then turn into a string)

My bad, I typed it wrong image is Pic