Tween whatever you want, however you want.
Roblox Model | Wally | GitHub Release
Tweens interpolate a number from start to end over a defined time, and there are better solutions for other problems.
For example, Spring is great for physics-based movement.
A simple example for moving a part, using PivotTo.
local FunctionTween = require(path.to.FunctionTween)
local PartToMove = workspace.PartToMove
local StartingPivot = PartToMove:GetPivot()
local GoalPivot = StartingPivot * CFrame.new(0, 0, 10)
local tween = FunctionTween.new(function(t)
PartToMove:PivotTo(StartingPivot:Lerp(GoalPivot, t))
end, TweenInfo.new(1))
tween.Play(0, 1)API Reference
Creates a new FunctionTween table.
local RunService = game:GetService("RunService")
local FunctionTween = require(path.to.FunctionTween)
local easingFunction = function(x: number)
return x ^ 2
end
local tween = FunctionTween.new(
-- The function to tween
function(t)
PartToMove:PivotTo(StartingPivot:Lerp(GoalPivot, t))
end,
-- Can be a `TweenInfo` or a table with `TweenInfo` and `EasingFunction`
{
TweenInfo = TweenInfo.new(1),
EasingFunction = easingFunction
},
-- What to update the function on (Based on MethodTween)
RunService.Stepped
)Plays the tween.
tween.Play(
-- Start number
0,
-- End number
1,
-- Can be extended like `.new`'s TweenInfo
TweenInfo.new(1)
)Pauses the tween.
tween.Pause()Resumes the tween after it was paused.
tween.Resume()Cancels the tween, it cannot be resumed.
tween.Cancel()The playback state of the tween.
Fires when the tween is completed.
tween.Play(0, 1)
tween.Completed:Wait()
print("Tween completed!")Returns a value between valueA and valueB based on alpha, used internally for Equivalents.
print(FunctionTween.LerpValue(0, 100, 0.5)) -- Prints 50Equivalent to TweenService:Create
local PartToMove = workspace.PartToMove
local tweenFunc = FunctionTween.InstanceProps(
PartToMove,
{ CFrame = PartToMove.CFrame * CFrame.new(0, 0, 10) }
)
local tween = FunctionTween.new(tweenFunc)Equivalent to MethodTween.new
local PartToMove = workspace.PartToMove
local StartingPivot = PartToMove:GetPivot()
local GoalPivot = StartingPivot * CFrame.new(0, 0, 10)
local tweenFunc = FunctionTween.InstanceMethods(
workspace.PartToMove,
{ PivotTo = { StartingPivot, GoalPivot } }
)
local tween = FunctionTween.new(tweenFunc)You will need Rokit (or Aftman) to install tools.
You can rojo serve serve.project.json to a Baseplate for Tests in Workspace, and Packages in ReplicatedStorage.