Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I reference a specific frame after using i, v in pairs?

Asked by 4 years ago
Edited 4 years ago

I am making it so that a button can be dragged into different frames. I am stuck on the last part, wondering how to reference the right frame. I thought of using return, but I don't know how. Suggestions anyone?

game:GetService("UserInputService").InputEnded:Connect(function(KeyCode)
    if KeyCode.UserInputType == Enum.UserInputType.MouseButton1 then
        if Dragging == true then
            Dragging = false
            local FrameList = {Holder.ButtonHolder1, Holder.ButtonHolder2, Holder.ButtonHolder3}
            for i, frame in pairs(script.Parent.ButtonHolder:GetChildren()) do
                local Distance = (frame.AbsolutePosition - Image.AbsolutePosition).Magnitude
                table.insert(FrameList,Distance)
                wait(0.1)
            end
            print(FrameList[1])
            print(FrameList[2])
            print(FrameList[3])
            table.sort(FrameList)
            local ClosestFrame = FrameList[1]
            --Image.Position = Frame[1].Position
        end
    end
end)

Answer this question