This doesn’t involve any script, just a use case question.
On the DevHub page it says that Vector2 may be used to find the mouse position or work with Gui elements. What cases would you use Vector2 instead of UDim2, and what are some benefits to Vector2 instead of using UDim2?
The thing is, mouse position doesn’t have offset (or i think so). It only uses to values, x and y. GUI positions use 4 values, x, x offset, y, y offset.
A Vector2 is just that, a vector with 2 axes (meaning it exists in 2d space). Like all vectors, it has a direction and magnitude. It’s a vector in 2d space. A UDim2 is “Universal Dimensions” 2, The 2 means 2 dimensions. UDims aren’t like vectors, they don’t really have a magnitude or direction and are used typically for GUI objects.
UDim2 and Vector2 are similar, however they differ slightly in use cases.
Vector2 is applicable in the 3D environment in case the third vector is not necessary. Maybe it’s majorly used for, for instance, top-down real-time strategy games or basic turn-based card games.
UDim2 is more appropriate for GUI designs, since it contains two properies per axis: Scale and Offset. One is adjustable to monitor size while offset is fixed per pixel. I believe you could convert Vector2 to UDim2