I question popped in my head.
"How can I list all the items in a player's backpack?"
I tried to make it work but it utterly failed...
So, I was wondering if anyone would be willing to teach me all the things that would be included in lists.
Volodymyr2004 suggested using a for loop
. Don't. Use a pairs loop
. Pairs loops are made specifically for this purpose.
1 | local backpack = player.Backpack |
2 | local children = backpack:GetChildren() |
3 |
4 | for i,v in pairs (children) do |
5 | print (v.Name) |
6 | end |
Good Luck!
You can get the children of backpack,
1 | local tools = BackPack:GetChildren() |
Then you can list of the items 1 by 1 in a loop until all items have been listed
1 | for i = 1 , #tools do --will go through children 1 by 1 |
2 | print (tools [ i ] .Name) --prints tool's name |
3 | end --end |
Hope this helped!