Attempt to index nil with image id

Hi, im trying to make an inventory system where it shows the image of the item, however when i go to add the image of the item, it gives me the error, ‘attempt to index nil with image id’

module script (stores the items and images)

m.Items = {
	{
		name="Dark Bandana";
		imageID="17077089933";
		rarityType="Common";
	};
	{
		name="Dark Shades";
		imageID="17077078542";
		rarityType="Common";
	};
	{
		name="Dramatic Mask";
		imageID="17077078644";
		rarityType="Uncommon";
	};	
	{
		name="Fedora";
		imageID="17077078435";
		rarityType="Rare";
	};	
	{
		name="Red Bandana";
		imageID="17077090356";
		rarityType="Uncommon";
	};	
	{
		name="Old Boot";
		imageID="17077078756";
		rarityType="Epic";
	};	
	{
		name="Topaz Fedora";
		imageID="17077078905";
		rarityType="Impossible";
	};	
}

local script

local UserInputService = game:GetService("UserInputService")
local template = script:WaitForChild("Template")
local List = script.Parent
local module = require(game.ReplicatedStorage.Items)
local b = require(game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Modules"):WaitForChild("case"))
	game.ReplicatedStorage.Cases.GetItem.OnClientEvent:Connect(function(unboxed)
		print(unboxed)
		local button = template:Clone()
		button.Visible = true
		button.Parent = List
	button.ImageLabel.Image = "rbxassetid://"..module.Items[unboxed].imageID -- problematic line
	
	end)

Issue is most likely what unboxed is. The index for Items is numbers like 1,2,3,4,5,6…
Whatever unboxed is it needs to match the index of the items in your table or you can manually set the index for each item to simplify it a little I guess.

m.Items = {
	["DarkBandana"] = {
		name = "Dark Bandana";
		imageID = "17077089933";
		rarityType = "Common";
	}
}
1 Like

unboxed is the name of the item in the table so if you rolled dark bandana, unboxed would = “Dark Bandana”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.