Hey there!
I know this should seem really simple but I am not getting it, I know the basics of tables, but this is a different kind of table… I got this from a tutorial so bear with me.
This table
_G.boughtArray = {}
can be used for any player by calling it like this
local bought = _G.boughtArray[player.userId]
Instead of using table.insert, it uses this to add items to the table
_G.boughtArray[player.userId][Item] = Item
So I am a little unsure how to take items back out. Here is my code block
for i, ITEM in pairs(_G.boughtArray[player.userId]) do
print(ITEM)
print(_G.boughtArray[player.userId])
print(_G.boughtArray[player.userId][ITEM])
table.remove(_G.boughtArray[player.userId], _G.boughtArray[player.userId][ITEM])
end
the 3 print lines gave
-
the current item
-
the whole table
-
the current item
but, when I tried to remove the item, I got
What I want to know, how can I take out the item, and how can I reference it using a number?