Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Tweening only one variable of a Gui?

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

✓ Accepted answer

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)

6 comments

0

Do I have to add the Y as well?

0

I don't understand what you mean.

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)

0

I edited my answer to show adding to the Y axis.

0

Oh, so it works both ways?

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.