Introduction
MethodTween allows you to animate non-tweenable properties such as Scale & CFrames of models, through an API that aims to replicate Roblox’s by as much as possible. The implementation includes support for reversing, delays, repeats & different tweening styles and directions.
How to Use
Due to the getter & setter methods being separate & using separate namings (e.g., GetPivot()
and PivotTo
, or GetScale
& ScaleTo
), each field accepts an array of two values; the start and end value to tween to-and-fro, like so:
MethodTween.new(Object, TweenInfo.new(...), {
ScaleTo = {0.5, 1} -- Start from 0.5 and end at 1
}):Play()
Outside of the differing property tables, the rest of the API behaves exactly the same as Roblox’s - it runs every Stepped
, supports methods such as :Cancel()
& :Pause()
, and has a PlaybackState
variable to describe it’s current state. It additionally has a Completed
event.
Observers
If you feel the library doesn’t allow you to do enough, or want to add custom behavior on top, you can use Observers.
Simply put, observers allow you to listen to the alpha value each frame, like so:
local Tween = MethodTween.new(Part, TweenInfo.new(1), {})
local id = Tween:Observe(function(Alpha)
print(Alpha)
end)
Tween:Play()
task.wait(0.5)
Tween:StopObserving(id)
Installation
The module is available both on wally & on Roblox:
Misc.
The source can be found on my GitHub.