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

How do I tween this UI's position?

Suppose I have a Frame's position is

UDim2.new(0,0,0)

and I want to tween the Frame's position X by 2, how do I do that? I tried the following but it returns an error.

frame:TweenPosition(UDim2.new(frame.Positon.X - 2, frame.Position.Y, frame.Position.Z)

Thanks:)

2 answers

This is pretty easy to do when you get the hang of it.

All you need to do is define a frame, textbox, textlabel, etc. (basically any GUI object) and just put: TweenPosition() on the end of it with 4 properties.

Example:

local frame = script.Parent

frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1)

0.5, 0, 0.5, 0 will basically tween it to the middle of the screen. Assuming, its a frame and you didn't resize it. But you can put any position in there.

For more information, you can go here

2 comments

0

Oh and the correct thing to do would be to do this: (0, frame.Position.X, 0, frame.Position.Y)

0

-2 foreach.

I want to tween it base on it's original position, for an example, if it'x X is 0, I want it to tween to 0.5, if It's 0.3, I want it to tween to 0.8.

1 comment

0

Then just add 0.5

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