How to find a distance between two gui?

I am trying to make a script that shows the distance between the middle of two guis

here is my script:

local function Distance(Gui1, Gui2)
    local X =Gui1.AbsolutePosition.X - Gui2.AbsolutePosition.X
  local Y = Gui1.AbsolutePosition.Y - Gui2.AbsolutePosition.Y
local dis = math.sqrt(2^X + 2^Y)
    return dis
end

The Vector2 datatype has a Magnitude property, which works in the same way Vector3.Magnitude does

4 Likes

does it find the distance from the center???because the results is not constant
eg) when i put frame 1 on top of frame to, the distance is 20 .But when I put frame 1 below frame 2, the result is 40

If you get the position property, taken the anchor point is 0.5,0.5 it should get the middle

It still do not work =((((((((((((((((((((((((((((((((((((

there is something called Google it is a pretty neat invention