Attempt to index nil module script

im trying to get the type of the item in my dictionary i made but it keeps returning nil even tho it it is there. the error is attempt to index nil with ‘Type’
local script

local function LoadInventory()
	ClearInventory()
	
	local buttonsCreated = 0
	for id, amount in pairs(invData) do
		local itemInfo = localModule.GetItemInfo(id)
		if itemInfo.Type.Stackable then
			CreateInventoryButton(itemInfo.Image, amount)
			buttonsCreated += 1
		else
			buttonsCreated += amount
			for i=1, amount do
				CreateInventoryButton(itemInfo.Image, "")
			end
		end
	end
	for i=buttonsCreated+1, 20 do
		CreateInventoryButton("", "")
	end
end

module script

local itemTypes = {
	Potion = {
		Stackable = true,
		MaxStack = 10
	},

	Equipment = {
		Stackable = false
	}
}

local itemsInfo = {
	["1"] = {
		Name = "Potion",
		Image = "rbxassetid://7862622341",
		Type = itemTypes.Potion,
		Description = "amogus potion"
	},

	["2"] = {
		Name = "Sword",
		Image = "rbxassetid://7863601994",
		Type = itemTypes.Equipment,
		Description = "amogus sword"
	}
}

function module.GetItemInfo(id)
	return itemsInfo[id]
end

2 problems.

  1. There is no table named “module” inside of the module script, which means module.GetItemInfo is nil
  2. You never return anything.
local module = {} --create the module table

local itemTypes = {
	Potion = {
		Stackable = true,
		MaxStack = 10
	},

	Equipment = {
		Stackable = false
	}
}

local itemsInfo = {
	["1"] = {
		Name = "Potion",
		Image = "rbxassetid://7862622341",
		Type = itemTypes.Potion,
		Description = "amogus potion"
	},

	["2"] = {
		Name = "Sword",
		Image = "rbxassetid://7863601994",
		Type = itemTypes.Equipment,
		Description = "amogus sword"
	}
}

function module.GetItemInfo(id)
	return itemsInfo[id]
end

return module --return the table

the module script is kinda long so i only included the main problems of both scripts its there.

Then, the only other problem I could think of is the fact that it gets the information off of the id, meaning the id isn’t the same as you are passing. What exactly are you passing? If it is a number for the id, you would need to use tostring() to turn it into a string for it to return.

its getting the numbers off itemsinfo but the numbers are already in a string so im not sure that is the problem

try to print the returned value, the returned value is nil as the error says.

I fixed it, it was a syntax error