I've been fooling around with this for a little while and I am a bit stumped. How would I create a table, insert players into that table when they join, and then insert another table inside the players tables to be able to iterate through them?
local players = {}
game.Players.PlayerAdded:Connect(function(player)
table.insert(players,player)
end)
local function GenerateInventory()
local InventoryTable = {
Item1 = nil,
Item2 = nil,
Item3 = nil
}
table.insert(players,InventoryTable)
end
local function GenerateItem()
local Table = {
Count = 1,
Durability = 100,
Cost = 50
}
--Now how would I insert this into the table, replacing the first Item# that == nil with the table?
end
-- Should look like this
local players = {
InventoryTable = {
Item1 = {
Count = 1,
Durability = 100,
Cost = 50
},
Item2 = nil,
Item3 = nil
}
}
--Now lets say I need to find out how much durability the current item has. How would I iterate through these tables to find the item I am using, and how much durability it has?

1 comment
use PlayerAdded event, then do something like players[PlrAdded.UserId] = {TABLE}