What is Vector2 and is it related to udim?

I have just heard about Vector2 which is Vector3 but for 2D Space, but the only thing that are “2D” in roblox are GUIs so that got me wondering, is Vector2 used for GUI and is it any different from udim? Plus, can I use it for gui position checks?

UDim Applies a Scale and a Offset to a 2D object, mainly with Guis, but you would probably see UDim2 for that usage to apply Scales and Offsets on both Axis.

Edit: UDim Appearently is a One Dimensional Value

The only use I have seen with Vector2 would be with:
AnchorPoint, AbsoluteSize, or AbsolutePosition

As those only take in 2 numbers and not 4 like the Others
Vector2: 0,0
UDim2: {0,0}, {0,0}

2 Likes

Aren’t they both X and Y?

Yes, but unlike Vector2, UDim2 contains two more values for their Scale and Offsets, and Size and Position require a UDim2, not a Vector2

UDim2.new(xScale, xOffset, yScale, yOffset)

Vector2.new(x, y)

However you can use UDim2.fromScale or fromOffset:

UDim2.fromScale(xScale, yScale)
UDim2.fromOffset(xOffset, yOffset)

It could just be they made them for Different uses.

1 Like

Vector2 helps figure out where things are in the game, like characters, objects, and terrain. It’s not just for the GUI.

UDim is only for the GUI and helps control how big and where it appears on the screen.

You can use Vector2 to check where things in the GUI are on the screen. But if you want to move and resize the things in the GUI, you need to use UDim2 instead of Vector2. UDim2 lets you control both the position and size of GUI elements.

1 Like

So I can use it to check if certain frames are near each other without the use of absolute position?