How to convert UDim2 (Set of Scale + Offset) to Vector2 (Absolute Size)?

Hi, As you may seen the title, I’m having problem with UDim2 to Vector2.
I recently making a script: “If the vertical AbsoluteSize is bigger than horizontal AbsoluteSize”.

But I don’t know how do I convert UDim2 to Vector2.
Does somebody has nice idea? Thank you.

Well to convert you would need to implement this yourself - the scale part of UDim2 depends on the size of the parent, so you would multiply the scale paremeters by the absolute size of the parent GUI. Then you add the offset.

local AbsoluteSize = Vector2.new(
    Gui.Parent.AbsoluteSize.X * UDim2.Size.Scale.X + UDim2.Size.Offset.X,
    Gui.Parent.AbsoluteSize.Y * UDim2.Size.Scale.Y + UDim2.Size.Offset.Y
)

If the parent is a screen gui, use the screen size instead.

But why don’t you just use AbsoluteSize of the GUI object originally? It would give you the same thing without having to go through this calcuation

1 Like

The AbsoluteSize of GUI object can be changed, so I wanted to calculate.
Thank you for the advice!

1 Like