How to freeze a GuiObject that is in the middle of tweening its size?

I’m trying to make a timer bar that slowly shrinks the size of itself on the Y axis, which is in sync with a timer. It uses GuiObject:TweenSize() to accomplish this. Only problem being, how do I freeze the bar if the timer stops before reaching zero?

This is what I’ve tried to use to accomplish shrinking the timer bar:

timerbar.TimeLeft:TweenSize(UDim2.new(1,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, timer.Value.Value, false)

Can anyone help me accomplish stopping the timer bar in the middle of shrinking? Thanks.

You must use the function:

TweenSizeAndPosition()

TweenSizeAndPosition(Udim2.new(size), Udim2.new(position of the object before to get resized), Enum.EasingDirection.Out, Enum.EasingStyle.Liner, 1) --change EasingStyle.Linear with the one you want and 1 with the time you need to resize the gui.

No, no offense, but I don’t think you understand.
I want to basically pause the tween. So it stops right where it is, I don’t want to put it back to the beginning.

Set the override to true and then just tween it to its current size I believe. Basically, set the false in that line to true and when the timer or whatever you have stops, just make it tween the TimeLeft object to its current size on the y axis

Override must be true so another tween can interrupt the current tween on it, if it’s false, this wont work

1 Like

Use TweenService

When the Timer stops call Tween:Cancel()

5 Likes