General purpose modules for Roblox development. [Read-only Codeberg mirror]
1# TweenSequence
2
3Play a sequence of tweens, waits, parallel tween groups, and callbacks with support for pausing and resuming mid-sequence.
4
5## Types
6
7### `TweenSequenceType`
8
9```
10{ number | Tween | {Tween} | () -> () }
11```
12
13A sequence is an ordered array of items. Each item is processed one at a time (except parallel groups), in the order it appears. Supported item types:
14
15| Type | Behaviour |
16| ------------- | ----------------------------------------------------------------------------------------------- |
17| `number` | Waits for that many seconds before advancing. |
18| `Tween` | Plays the tween and waits for it to complete before advancing. |
19| `{Tween}` | Plays all tweens in parallel. Waits for the longest one to complete before advancing. |
20| `() -> ()` | Calls the function immediately and advances. No waiting. |
21
22---
23
24## Constructor
25
26### `Create`
27
28`Create(sequence: TweenSequenceType)` → `TweenSequence`
29
30Creates a new `TweenSequence` from the provided sequence. Does not begin playback automatically.
31
32#### Parameters
33
34| Name | Type | Required |
35| -------- | -------------------- | -------- |
36| sequence | `TweenSequenceType` | Yes |
37
38#### Returns
39
40| Type |
41| --------------- |
42| `TweenSequence` |
43
44#### Example
45
46```lua
47local seq = TweenSequence.Create({
48 tweenA, -- plays tweenA, waits for completion
49 1.5, -- waits 1.5 seconds
50 { tweenB, tweenC }, -- plays tweenB and tweenC in parallel, waits for longest
51 function() print("done!") end,
52})
53seq:Play()
54```
55
56---
57
58## Properties
59
60### `Playing`
61
62`Playing: boolean`
63
64`true` while the sequence is actively running. Set to `false` when the sequence completes or is paused.
65
66---
67
68## Methods
69
70### `Play`
71
72`Play()` → `void`
73
74Plays the sequence from the beginning. Each item in the sequence is processed in order.
75
76---
77
78### `Pause`
79
80`Pause()` → `void`
81
82Pauses the sequence at the current step. Any actively playing `Tween` instances at that step are also paused. The elapsed time within the current step is retained for use by [`Resume`](#resume).
83
84---
85
86### `Resume`
87
88`Resume()` → `void`
89
90Resumes the sequence from where it was paused. Completes the remaining duration of the current step (accounting for elapsed time) before advancing to subsequent steps.
91
92Does nothing if the sequence is already playing or has not been started.