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

Tweening only one variable of a Gui?

Asked by 10 years ago

I want to do this:

:TweenPosition(UDim2.new(x.Offset = 40), "Out", "Quad", .1)

But the normal formula is:

:TweenPosition(UDim2.new(0, 40, 0, 0), "Out", "Quad", .1)

How would I execute the first one? If you ask why I cant use the second one, it's because the function finds a GUI (which have different positions) and I don't want to make them all 0 on the Y axis. I want the Y axis to remain as it is.

1 answer

Log in to vote
1
Answered by 10 years ago

Then, you could use this:

(Assuming gui is the GUI we're tweening)

gui:TweenPosition(UDim2.new(gui.Position.X.Scale, 40, gui.Position.Y.Scale, gui.Position.Y.Offset), "Out", "Quad", .1)

If you wanted to add 40 to the Y position (move it downward):

gui:TweenPosition(gui.Position + UDim2.new(0,0,0,40), "Out", "Quad", .1)
0
Do I have to add the Y as well? Orlando777 315 — 10y
0
I don't understand what you mean. User#11893 186 — 10y
0
Sorry about that. By adding the Y I mean, couldn't I just type this?:(UDim2.new(gui.Position.X.Scale, 40) Or it would give me an error since it doesn't follow a certain format of(X scale, X offset, Y scale, Y offset) Orlando777 315 — 10y
0
I edited my answer to show adding to the Y axis. User#11893 186 — 10y
View all comments (2 more)
0
Oh, so it works both ways? Orlando777 315 — 10y
0
The first one will set the X offset to 40 absolutely. It doesn't add it to the current value. The second example will ADD 40 to the Y offset, moving it down. User#11893 186 — 10y
Ad

Answer this question