TweenSizeAndPosition time

Hey there!

So i want to give a TweenSizeAndPosition a certain amount of time to Tween. Is that possible?

Any help is appreciated!

1 Like

Yes! This is possible. If you use the TweenPosition you can do this:

Frame:TweenPosition(UDim2.new(0, 0, 0, 0), "EasingDirection", "Easing Style", "Time")
--The "Time" would be the amount of seconds you would like to have the Tween be!

Hope this helps!

4 Likes

Yes, Like any other tween you’re able to adjust the time.

TweenSizeAndPosition(UDim2.new(0,0,0,0), UDim2.new(0,0,0,0), --time Easing Direction EasingStyle

Not in that order in this order

"EasingDirection" "EasingStyle" "Time"
1 Like

Yes! But as a reminder, please make sure you researched before asking! There is a developer hub page which answers your question.

Anyways, like the other methods TweenPosition and TweenSize, there will be a time. The parameters are:

GuiObject:TweenSizeAndPosition(UDim2 Size, UDim2 Position, EasingDirection, EasingStyle, Time, bool override, callback
1 Like

I prefer using TweenService.

local TweenService = game:GetService("TweenService")
local Frame = -- path to a gui Frame instance

local TweenInformation = TweenInfo.new(
    .4, -- how long the tween takes
    Enum.EasingStyle.Cubic, -- the easing style of the tween
    Enum.EasingDirection.Out, -- the easing direction of the tween
    0, -- amount of times the tween will repeat (-1 goes infinitely)
    false, -- true means the tween reverses, false means it does not
    0 -- delay time before tween begins
)

local myTweenAnimation = TweenService:Create(
    Frame, -- the instance I want to animate
    TweenInformation, -- the TweenInfo instance I want to describe my animation
    { -- a dictionary of the Frame properties that will be animated
        Size = UDim2.new(),
        Position = UDim2.new()
    }
) -- TweenService:Create() returns a Tween animation

myTweenAnimation:Play() -- plays the animation on the Frame using the TweenInformation and altering the Size / Position properties to be what you want

myTweenAnimation.Completed:Connect(function() -- the Tween.Completed event fires when the animation is complete; in this case we do a print statement when it finishes
    print("myTweenAnimation finished!")
end)
3 Likes