Hi, I've made a scrollbar frame that is supposed to list every item in the players backpack. Ill show you what I've done so far before I explain what is wrong.
And just for reference if you're going to post an answer where it checks if a certain item exists in the backpack then doesn't add it again... The player can have more than one of that item if they wish.
local itemTemplate = script.Parent.Item
player = script.Parent.Parent.Parent.Name
items = {}
itemY = -50
while true do
local backpackItems = game.Players[player].Backpack:getChildren()
for i=1,#backpackItems do
table.insert(items, backpackItems[i].Name)
itemY = itemY + 50
print(player .. " has " .. items[i])
if #items <= #backpackItems then
local a = itemTemplate:Clone()
a.Parent = script.Parent.ScrollingFrame
a.Position = UDim2.new(0, 0, 0, itemY)
a.Text = items[i]
a.Visible= true
end
end
items = {}
itemY = 0
wait(0.5)
end
There are a few bugs I can get my head around ill list them here;
- The starting item is one black pickaxe, but for some reason the UI outputs two. I've uploaded a picture below https://gyazo.com/ff243a9ecd690c9648763f22b261edc2
- Also I have to clear the table each loop to allow it to add more items, otherwise it thinks you've got 4 pickaxes when you could have two. Which causes there to be an unlimited amount of text buttons (Image below)
I've definitely gone horribly wrong somewhere and can quite work out ways around this. Maybe i'm just too tired at the moment, who knows?
But anyway if you've got any idea on how to fix this ill greatly appreciate it! Thanks, Cuv

1 comment
Well that literally just fixed everything, Thanks for that!