i have no idea how to count the children of the player's backpack
i tried to do it with loops but that counted all of the items in the inventory when i just need the total number of items (i did it in a loop because when i pick something up i want it to recount the number of items)
local i = 1 while i < 10 do bpitems = BackPack:GetChildren() for i = 1, #bpitems do print(i, bpitems[i].Name) hmi.Value = i print(hmi.Value .. 'This is the value') end wait(0.2) end
(when i did this it counted all the things one for one i just need it to say something like you have 5 total items NOT like "1","2","3","4","5" )
You can use the #
operator on a table to get its length. In this case, use #
on Backpack:GetChildren()
to get the number of all direct children of the backpack.
print("You have", #BackPack:GetChildren(), "total items")
It is pretty simple, make a custom backpack cause the default one can' t be edited.