DynamicTween [Open-Source] - Tween Anything

DynamicTween Release [v2]

  • Note: This module was initially created for personal use but has been open-sourced. Feel free to leave feedback.

Overview

DynamicTween replicates Roblox’s TweenService, adding Bezier curve support for advanced movement animations.
It specializes in dynamic animations for Roblox instances.

Features

  • Familiar Interface: Functions similarly to TweenService:Create(...) for creating tweens on Roblox instances.
  • Bezier Curve Support: Allows you to create natural motion paths with Bezier curves.
  • Dynamic Tweening: Specialized support for smooth animations of moving positions.
  • Model Tweening: Allows you to tween models, using :PivotTo()

Example Usages

Example 1 | Basic Tween for Position
local DynamicTween = require(path.to.DynamicTween)

local part = workspace.Part -- Replace with your part
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local propertyTable = {
	Position = Vector3.new(0, 10, 0) -- Move part to this position
}

local tween = DynamicTween:Create(part, tweenInfo, propertyTable, { Play = true })
Example 2 | Tween with Bezier Curve
local DynamicTween = require(path.to.DynamicTween)

local part = workspace.Part -- Replace with your part
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

local propertyTable = {
    Position = Vector3.new(20, 10, 20) -- End position
}

local curveOffset = Vector3.new(10, 15, 0) -- Control point for Bezier curve

local tween = DynamicTween:Create(part, tweenInfo, propertyTable, { Play = true, Curve = curveOffset })
Example 3 | Tweening Model Pivot Using CFrame
local DynamicTween = require(path.to.DynamicTween)

local model = workspace.Model -- Replace with your model
local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local propertyTable = {
    CFrame = CFrame.new(Vector3.new(20, 0, 20)) -- Move model to this CFrame
}

local tween = DynamicTween:Create(model, tweenInfo, propertyTable, { Play = true })
Example 4 | Pausing and Resuming Tween
local DynamicTween = require(path.to.DynamicTween)

local part = workspace.Part -- Replace with your part
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)

local propertyTable = {
    Position = Vector3.new(10, 20, 10)
}

local tween = DynamicTween:Create(part, tweenInfo, propertyTable, { Play = true })

wait(2) -- Let the tween run for 2 seconds
tween:Pause() -- Pause the tween

wait(2) -- Wait before resuming
tween:Play() -- Resume the tween

Methods, Properties & Events

For more details on the methods, properties, and events supported, refer to the TweenService Documentation.


Get the Model Here

Feel free to leave suggestions or report bugs. I’ll address them as quickly as possible.

19 Likes

Currently working on a big Update, (more optimization) and

  • Support for models
  • Support for RepeatCount, Reverse & DelayTime in the ConnectHeartbeat (Dynamic Tween) function

If you are currently using the V1, some things will change, Other.IsMoving will be removed. You can directly pass an instance as the Value or CFrame & Position.

2 Likes

_ V2 Just Released _

Changelog:
- [17/09/2024]: Changed, removed and added some new arguments.
- [17/09/2024]: Added support for Models, and the other TweenInfo arguments.

2 Likes

this seems very helpful glad u made this :+1:

2 Likes

I love making open-sourced modules, if you have any suggestions for this or another module feel free to a suggestion here

2 Likes

ooh yeah I think a good tween library should focus on animation algorithms or general timing that is the main feature missing from the native tweening library so seeing bezier curve here is cool. A custom tweening function I made for my boids library is one that is designed for navigation whereas the block moves a short distance on the path and faces the direction of movement before continuing instead of interpolating the turning angle for the entire distance of movement.

Seems pretty cool, been looking for a tween module to standardize my stuff, thanks.

1 Like

Looks like a decent module, but it’s not letting me tween a model.
TweenService:Create no property named 'CFrame' for object
is the error I’m getting.

Can you show me your code so I can assist you?

I’ve found the source of the error, I will be updating the module.

1 Like

I copied what you had for the example for Model tweening.

I’m making another cleaner version that supports models as the CFrame or Position argument, more optimization and typechecks will be added.

And fix all the bugs I’ve discovered.
For now here’s the fix for your problem

Line 60:

-- Handle Dynamic Table and Model-specific logic
	if InstanceType == 'BasePart' then
		if typeof(PropertyTable.Position) == 'Instance' then
			DynamicTable.Position = PropertyTable.Position
			PropertyTable.Position = nil
		end
		if typeof(PropertyTable.CFrame) == 'Instance' then
			DynamicTable.CFrame = PropertyTable.CFrame
			PropertyTable.CFrame = nil
		end
	elseif InstanceType == 'Model' then
		if typeof(PropertyTable.CFrame) == "CFrame" then
			DynamicTable.CFrame = {['CFrame'] = PropertyTable.CFrame}
		else
			DynamicTable.CFrame = PropertyTable.CFrame
		end
		PropertyTable.CFrame = nil
		ModelCFrameValue = Instance.new('CFrameValue')
		ModelCFrameValue.Value = _Instance.WorldPivot
		ModelCFrameValue:GetPropertyChangedSignal('Value'):Connect(function()
			_Instance:PivotTo(ModelCFrameValue.Value)
		end)
	end
1 Like

Just a suggestion but could you make the model to where it replicates tweens to the clients like if you need something to tween for every player without running the tween on the server. But this model seems very useful thanks for making it available

The module works on both client and server, this is just the tweenservice but as a module

nvm I know what you’re talking about, I’ll make a network module

1 Like