How to find the position between two UDIM2 positions

Simple question
How to be able to find the position between two UDIM2 positions

I`ve tried searching but didnt manage to find anything helpfull
and I tried doing (UDim2 + UDim2) / 2 when it errored I tried doing

UDim2.new(
(UDim2.X.Scale + UDim2.X.Scale) / 2 ,
(UDim2.X.Offset + UDim2.X.Offset) / 2,
(UDim2.Y.Scale + UDim2.Y.Scale) / 2
(UDim2.Y.Offset + UDim2.Y.Offset) / 2
)

but it didn`t work once again
any Help in appriciated!

You’re getting the average of the two, not the difference. Remove the /2 and use the - sign instead.

1 Like

This is straight forward given one understands the properties of a GuiObject.

local PositionSum = GuiObject.AbsolutePosition + GuiObject2.AbsolutePosition 
local CenterPosition = PositionSum / 2

Note: This is a Vector2 value, so you’ll need to input it as an offset position value instead of scale.

As in:

UDim2.new(0,CenterPosition.X, 0, CenterPosition.Y)
2 Likes

wait no sorry i thought you want the center of two udim

1 Like

do you mean (UDim2.X.Scale - UDim2.X.Scale)?

After trying with

UDim2.new(
(NextPoint.X.Scale - Point.X.Scale) / 2,
(NextPoint.X.Offset- Point.X.Offset) / 2,
(NextPoint.Y.Scale - Point.Y.Scale) / 2,
(NextPoint.Y.Offset- Point.Y.Offset) / 2)

and it worked!