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).
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
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.
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