How do I get multiple values from a module script?

hello, how do I get the name of multiple values from this module script?

local ItemInfo = {
	
	-- resources
	["Dirt"] = { -- need this name

		["ItemRarity"] = "F", -- dont need these
		["ItemType"] = "Resource",
		["MaxStack"] = 99,

	},

	["Grass Fibers"] = { -- need this name

		["ItemRarity"] = "F",
		["ItemType"] = "Resource",
		["MaxStack"] = 99,

	},

	["Logs"] = { -- need this name

		["ItemRarity"] = "E",
		["ItemType"] = "Resource",
		["MaxStack"] = 49,

	}	
}


return ItemInfo

Can you explain your question a little bit more? What are you trying to achieve?

Im trying to get the name of each value in that table(the commented ones), and I want to check if the name is the same as the name a player would pick up. if they were, I would take that item and use the key values inside to do other stuff essentially, if that makes sense.

-- send item to player's inv
for _, Item in pairs(Items) do
	Item.ProximityPrompt.ActionText = Item.Name

	Item.ProximityPrompt.Triggered:Connect(function(plr)	
		for i, v in pairs(plr.Inventory:GetChildren()) do
			if v.Name == Item.Name then
				if v.Value <= 99 then
					v.Value = v.Value + 1
					InventoryRE:FireClient(plr, Item)
					Item:Destroy()
				end
			end
		end
	end)
end
-- modulescript inside ReplicatedStorage named Items

return {
	["Dirt"] = {
		["MaxStack"] = 99,
	},
	["Grass"] = {
		["MaxStack"] = 9,
	},
}

-- any other script

local items = require(game.ReplicatedStorage.Items)

print(items.Dirt.MaxStack)
print(items["Grass"]["MaxStack"])

-- print all names with there max stack
for name, data in pairs(items) do
    print(name, data.MaxStack)
end
2 Likes