Vector2 vs UDim2?

What’s the difference between Vector2 vs UDim2? Not the similarities, but you can include that if you want.

2 Likes

Vector2 is a 2D space in a 3D workspace.
UDim2 is just a 2D space for GUIs.

Imagine UDim3s and a 3D GUI workspace… just imagine the possibilities…

You mean ViewportFrame? I’m guessing Vecto2 is for BillboardGUI and UDim is for ScreenGui.

Vector2s are used for UI elements and 2D mouse positions. You should read this article about them.

Ya… sounds just like UDim2 in disguised. Actually ik 2D mouse Position

It’s pretty plain to see if you just read the wiki

In short, UDim types have both an Offset property and a Scale property. Scale is a fraction of whatever the object is a child of, offset is a number of pixels.

1 Like

From what I understand, a UDim has two components: a Scale and an Offset
The Scale is a percentage and the offset is generally in pixels

Vectors don’t necessarily have to have a scale and offset

A vector is a vector and a universal dimension is a universal dimension. The names pretty much explain themselves. Reading the documentation would also really help here: UDim2 and Vector2.

Vector2 can be understood by knowing what a vector is. There are 2D and 3D vectors. The 2 in Vector2 stands for 2 dimensions (X and Y). UDim2 can be understood by knowing what UDim is. UDim represents a point on the screen, so UDim2 represents two points on the screen.

The first one makes sense and is easier to understand, but the second one has more information.
I don’t really know which one to mark as a solution.

So in summary, Vector2 is an X,Y point in a screen while a UDim2 is based off on a percentage of the screen and number of pixels to move.

Edit: Seems to me in simple definition that a Vector2 is like inputting a (X,Y) value in a calculator and seeing where that point position itself in a graph. While UDim2 are 2 things. Scale and Offset. Scale represents a percentage of the max number of pixels a screen has like a mobile phone screen, monitor or TV screen. While offset is the pixels of that screen. Some screens have 1080pixels, and some have 4k pixels. Not all screens have the same number of pixels, so it makes sense that scale exists.

1 Like

Vector2 just represents 2 numbers. Vector2 is usually used for transforming 2d objects relative to the world.

UDim2 is used for transforming 2d objects relative to a screen, which can be different for different devices. UDim2 has 2 Vector2s (I hope) for scale and offset.

Vector2
It shows the X and Y coordinates.
image

UDim2
It shows the X and Y coordinates, but it is divided into scale and offset.
The Scale is adjusted to the predecessor and Offset not.
image

Original:

Scale:

Offset:

1 Like

Why do you mean by 2D mouse? Aren’t all mouse icons 2D?

No, I mean the mouse position on the 2D screen.

1 Like