Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is TweenPosition and Udim2?

Asked by 6 years ago

Hello, I am coding an minigame etc. I made countdown gui. But i want to use it with TweenService

TweenPosition(UDim2.new --etc)

How can i use it? What is Udim2? Please dont send me Roblox wiki

1 answer

Log in to vote
2
Answered by 6 years ago

think of UDim2 values as the entirety of your screen. this is how they work:

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

The scale values represent the amount of screen something will always take up proportionally. For example, if something has a value of UDim2.new(0.5,0,0.5,0) it will take up half of ANY screen size. Let's say you have a 4K monitor and a 1080p screen: if you use the scale, any GUI will show up as the same relative size.

Think of offset as the number of 'pixels' wide or tall something is. If something has an offset of UDim2.new(0,100,0,100) then it will always be 100 x 100 'pixels' in size. Let's use the example of a 4K vs. 1080p screen using HARD numbers. If we assume that a 1080p screen has 2,000,000 pixels, then a 100x100 GUI on a 1080p screen would take up ~10,000 pixels out of the ~2,000,000 on screen. on a 4K monitor, it would take up ~10,000 pixels out of ~8.2 MILLION pixels on a screen. These screen size numbers aren't correct and they vary, but it goes to show that offset should **NOT **be used if you are looking for uniform size.

TweenPosition will lerp (interpolate; or smoothly transition) the position of a GUI to a different location. Its' parameters are like so:

TweenPosition(UDim2 endPosition, EasingDirection, EasingStyle, TweenTime, Override other tweens, callback)

Ad

Answer this question