I am trying to create a standard location for game Inventory items to be able to reference them for generating a ShopUI and Player data. I created a ModuleScript with the aim of having nested disctionaries(?) within it to store information.
local Inventory = {}
local Pets = {
["Pet1"] = {image = 12345678, cost = 10, desc = "A pet"};
["Pet2"] = {image = 23456789, cost = 20, desc = "A pet"};
}
local Weapons = {
["Gun1"] = {image = 987654321, cost = 10, desc = "A gun"};
}
return Inventory
I thought I could then loop through the Pets to clone a form with the required details, however ambition exceeds my skills once again, as when I try to reference
local inventory = require(game.ReplicatedStorage:WaitForChild("Inventory"))
local pets = inventory.Pets
print("Pets: ", pets)
The variables pets
always shows as nil
. I have tried creating the dictionary like so:
local Pets = {
Pet1= {image = 12345678, cost = 10, desc = "A pet"};
}
Neither seems to work. I just want to be able to create a variable that stores the Pets table from the ModuleScript, which I can then access to generate a Cloned form with all the details on for a Shop UI. How do I achieve this? I figure I a misunderstanding how to access that data within the module.