I’m trying too loop through 12 frames in one central frame but it doesnt seem to want to be working, and it only gets me the first frame in the explorer hierarchy, any ideas?
local function findNearestFrame()
for index,slot in ipairs(List:GetChildren()) do
if slot:IsA("Frame") then
for i,potentialItem in ipairs(List:GetDescendants()) do
for i,item in ipairs(Logs) do
if potentialItem.Name == item and potentialItem:IsA("ImageLabel") then
local equation = (itemLocation - slotLocation).Magnitude < 80
if equation then
print("An item is close to "..slot.Name)
end
for k in pairs(Logs) do
Logs[k] = nil
end
end
end
end
end
end
end
for i,potentialItem in ipairs(List:GetDescendants()) do
To:
for i,potentialItem in ipairs(slot:GetDescendants()) do
Since you’re first getting each child of List, and if it’s a frame, you’re then getting the descendants of List again, which is redundant, so I assume you meant to input the value from the previous loop.
So basically im making an inventory with a dragging system and right now I just need it to recognize which slot is closer so thats why Im looping through all of them
edit : Logs is something different and isnt important
local function findNearestFrame()
local equation = (itemLocation - slotLocation).Magnitude
for _,slot in pairs(List:GetChildren()) do
if slot:IsA("Frame") then
for _,item in pairs(slot:GetDescendants()) do
if table.find(Logs, item.Name) and item:IsA("ImageLabel") and equation < 80 then
print("An item is close to " .. slot.Name)
for _,v in pairs(Logs) do
Logs[v] = nil
end
end
end
end
end
end
I want it to output the frame that is closest to the item that the players is holding and it only works on the one that it spawns in when I pick up the item it seems
edit : I just needed to get the descendants of the main frame called list @Sterpant Thanks for trying to help @PhoenixRessusection Thanks for trying your best