What do the four numbers on a position of a gui in a script if it's only X and Y coordinates?

I’m just a bit puzzled on these 4 numbers of my scripts. Basically it just moves a gui to the designated coordinates but I dont understand on what each of the four number coordinates are since its only a X and Y.
Please explain what each of them are used for (yes I know what x, y and z coordinates are).

animframe:TweenPosition(UDim2.new(-1,-150,0,215),"In","Quad",.5,true)
2 Likes

two are offset and two are scale

the first two are offset and the last two are scale?

An UDim2 consists of 2 UDims, which have 2 arguments for their constructor, a Scale and an Offset

But basically
First number is the XScale, basically the location of the Gui in relation to your screen size in the X axis
Second number is XOffset, basically the location of the Gui in pixels starting from 0,0, the top left
Third number is YScale, same as XScale but for the Y axis
Fourth number is YOffset, same as XOffset but for the Y axis

Basically means

Move the GUI by -1 in the X axis Scale in relation to their screen size (off screen for the most part), offset it by -150 pixels, set the Y scale to 0 and offset it by 215 pixels

2 Likes

No, the first two are XScale and XOffset, last two are YScale and YOffset

@FrazedGreatness2 It’s not the same thing, OP Thought the first two were responsible for handling offsets and the last two for handling scales. Also UDim2 not Udim2, case sensitive.

2 Likes

Same thing offset is used to make it offset and scale makes it fit for all screens and is better for making sizes so it is

Udim2.new(XScale,XOffset,YScale,YOffset)

Offset and Scale are definitely not the same thing. Scale is calculated relative to the clients screen size. Scalar values derive from a percentage of the the screen resolution.
ScaleX = 300 / ResolutionX
This also makes conversion from scale to offset and vice versa really easy to calculate, all you have to compensate for is the clients view port size and its given inputs.

local ViewportSize = workspace.CurrentCamera.ViewportSize

local function ToScale(OffsetX, OffsetY)
  return OffsetX / ViewportSize.X, OffsetY / ViewportSize.Y
end

local function ToOffset(ScaleX, ScaleY)
  return ScaleX * ViewportSize.X, ScaleY * ViewportSize.Y
end
1 Like