I am trying to make an inventory system.
I currently have a table used to store a players data like this in a module script
PlayersData= {
["Gold"] = 100,
["Level"] = 1,
["Inventory"] = {
["Weapons"] = {
[1] = {
["Weapon"] = "Sword",
-- other information
}
},
["Armour"] = {
},
["Helmet"] = {
},
["Spells"] = {
}
},
["Equiped"] = {
["Equiped_Weapon"] = nil,
["Equiped_Helmet"] = nil,
["Equiped_Armour"] = nil,
["Spell_1"] = nil,
["Spell_2"] = nil
}
}
I am having trouble looping through the players inventory table. I want to be able to get all the items from the players inventory and place them into a grid layout.
Would I use a for loop to get the tables inside PlayersData[“Inventory”] then if the table is not nil use a for loop to get the items inside?