Tween
Tween is a static class used for tweening properties of instances, such as Position, Rotation and Size.
Multiple tweens can be applied on the same object at the same time, but they must not be tweening the same property. Only the latest tween will override any other one being applied to the property.
TweenColor, TweenNumber, TweenPosition, not Cancel) will return a tweenID in the form of a number used for things like cancelling a tween using the Cancel method.Summary
Methods
TweenColor:intTweenNumber:intTweenPosition:intTweenRotation:intTweenSize:intTweenVector2:intTweenVector3:intCancel:void
Methods
TweenColor
Tween:TweenColor(startValue: Color, endValue: Color, time: float, callPerStep: function, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
startValue | Color | - | |
endValue | Color | - | |
time | float | - | |
callPerStep | function | - | |
type | TweenType | - | |
callback | function | - |
Tweens a color between two specified values.
Example
Tween:TweenColor(Color.New(1,1,1,1), Color.New(1,1,1,0), 5, function(val)
part.Color = val
end, TweenType.linear, function()
print("Tween finished")
end)
TweenNumber
Tween:TweenNumber(startValue: float, endValue: float, time: float, callPerStep: function, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
startValue | float | - | |
endValue | float | - | |
time | float | - | |
callPerStep | function | - | |
type | TweenType | - | |
callback | function | - |
Tweens a number between two specified values.
Example
Tween:TweenNumber(1, 10, 1, function(val)
print(val)
end, TweenType.linear, function()
print("Tween finished")
end)
TweenPosition
Tween:TweenPosition(target: DynamicInstance, destination: Vector3, time: float, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
target | DynamicInstance | - | |
destination | Vector3 | - | |
time | float | - | |
type | TweenType | - | |
callback | function | - |
Tweens the position of a DynamicInstance
Example
Tween:TweenPosition(part, Vector3.New(100, 0, 0), 100, TweenType.linear, function()
print("I have arrived!")
end)
TweenRotation
Tween:TweenRotation(target: DynamicInstance, destination: Vector3, time: float, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
target | DynamicInstance | - | |
destination | Vector3 | - | |
time | float | - | |
type | TweenType | - | |
callback | function | - |
Tweens the rotation of a DynamicInstance
Example
Tween:TweenRotation(part, Vector3.New(0, 90, 0), 1, TweenType.linear, function()
print("Rotating finished")
end)
TweenSize
Tween:TweenSize(target: DynamicInstance, endValue: Vector3, time: float, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
target | DynamicInstance | - | |
endValue | Vector3 | - | |
time | float | - | |
type | TweenType | - | |
callback | function | - |
Tweens the size of a DynamicInstance
Example
Tween:TweenSize(part, Vector3.New(5, 5, 5), 1, TweenType.linear, function()
print("Sizing finished")
end)
TweenVector2
Tween:TweenVector2(startValue: Vector2, endValue: Vector2, time: float, callPerStep: function, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
startValue | Vector2 | - | |
endValue | Vector2 | - | |
time | float | - | |
callPerStep | function | - | |
type | TweenType | - | |
callback | function | - |
Tweens a vector2 between two specified values.
Example
Tween:TweenVector2(Vector2.New(0,0), Vector2.New(0,50), 5, function(val)
UIView.PositionOffset = val
end, TweenType.linear, function()
print("Tween finished")
end)
TweenVector3
Tween:TweenVector3(startValue: Vector3, endValue: Vector3, time: float, callPerStep: function, type: TweenType, callback: function): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
startValue | Vector3 | - | |
endValue | Vector3 | - | |
time | float | - | |
callPerStep | function | - | |
type | TweenType | - | |
callback | function | - |
Tweens a vector3 between two specified values.
Example
Tween:TweenVector3(Vector3.New(0,0,0), Vector3.New(0,50,0), 5, function(val)
part.Position = val
end, TweenType.linear, function()
print("Tween finished")
end)
Cancel
Tween:Cancel(tweenID: int)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
tweenID | int | - |
Cancels an on-going tween based on its tweenID.
local numberTween = Tween:TweenNumber(1, 10, 1, function(val)
print(val)
end, TweenType.linear, function()
print("Tween finished")
end)
-- the tweenID is the value of the variable
Tween:Cancel(numberTween)