Hi! I've recently attempted to draw a line from the origin of a circle to all 8 points on a square and then sort through all the sizes, and, in the end, returning the point that draws the smallest size to be used later. The code is shown below.

function closest_connection(icon, bullet)
    local p2 = bullet.AbsolutePosition + bullet.AbsoluteSize/2
    local smallest = math.huge
    local small_req = math.huge
    local connectors = {
        script.Parent.Icon.AbsolutePosition; --up left
        script.Parent.Icon.AbsolutePosition + Vector2.new(script.Parent.AbsoluteSize.X/2, 0); --up center
        script.Parent.Icon.AbsolutePosition + Vector2.new(script.Parent.AbsoluteSize.X, 0); --up right
        script.Parent.Icon.AbsolutePosition + Vector2.new(0, script.Parent.AbsoluteSize.Y/2); --center left
        script.Parent.Icon.AbsolutePosition + Vector2.new(script.Parent.AbsoluteSize.X, script.Parent.AbsoluteSize.Y/2); --center right
        script.Parent.Icon.AbsolutePosition + Vector2.new(0, script.Parent.AbsoluteSize.Y); --bottom left
        script.Parent.Icon.AbsolutePosition + Vector2.new(script.Parent.AbsoluteSize.X/2, script.Parent.AbsoluteSize.Y); --bottom center
        script.Parent.Icon.AbsolutePosition + Vector2.new(script.Parent.AbsoluteSize.X, script.Parent.AbsoluteSize.Y) --bottom right
    }
    for i, v in pairs(connectors) do
        local guessline = Vector2.new(((p2.X - v.X)^2 + (p2.Y - v.Y)^2)^0.5, 0)
        if guessline.X < small_req then
            small_req = guessline.X
            smallest = v
        end
    end
    return smallest
end

function circular_output()
    local point_draw = closest_connection(script.Parent.Icon, script.Parent.Bullet_Circle)
    local p1 = point_draw
...

And, uh, here is how it defines the point that drew the closest line. The upper left corner.

I can assume that's not the point drawing the closest line, but okay.

I tested if it was a debouncing issue by making the function only run a single time, but it yielded the same results. Any help?