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

Wait until TweenSize finishes before continuing script?

I read that TweenSize "Returns: bool" (http://wiki.roblox.com/index.php?title=API:Class/GuiObject/TweenSize) so after I run the function I want to wait until 'bool' is returned before continuing, but I'm not sure how to read it.

Frame:TweenSize (UDim2.new(0, 0, 0, 0), 2, 0, 4, false)
--How do I wait until the above code 'returns bool' before continuing the script?
Frame:TweenSize (UDim2.new(0.05, 0, 0.05, 0), 2, 0, 4, false)

2 comments

0

As far as I know, the script doesn't continue until the tween has finished.

0

I wish this was true, I could provide an example if needed. If I loop tweening it stop working because functions start to run into each other. I'm tweening a lot of parts so thats why this wait is needed.

1 answer

✓ Accepted answer

The very last parameter of the TweenSize function, along with both TweenPosition and TweenSizeAndPosition can be used to pass a callback function, which executes as soon as the tweening is complete.

It essentially works like so..

function executeAfter ()
	print("Tween complete")
end

GuiObject:TweenSize(UDim2.new(), Enum.EasingDirection.In, Enum.EasingStyle.Quad, 1, false, executeAfter) -- execute after will be called whenever the tween achieves its endSize, printing "Tween complete" to the output.

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