I'm currently working on a custom inventory UI for my game, this section of code goes through their backpack and scans through tools, it works just fine, however I'm wondering if there is a better way to approach this than just throwing a bunch of for loops in.
local function SetSlots()
for Backpack, ItemOne in pairs(Backpack:GetChildren()) do
if ( ItemOne:IsA("Tool") and ItemOne.Values.Slot[v] == 1) then
SlotContents.One = ItemOne
end
end
for Backpack, ItemTwo in pairs(Backpack:GetChildren()) do
if ( ItemTwo:IsA("Tool") and ItemTwo.Values.Slot[v] == 2) then
SlotContents.Two = ItemTwo
end
end
for Backpack, ItemThree in pairs(Backpack:GetChildren()) do
if ( ItemThree:IsA("Tool") and ItemThree.Values.Slot[v] == 3) then
SlotContents.Three = ItemThree
end
end
end
