SimpleTween is a module specifically made to improve
the experience of TweenService
This module includes many useful functions that can be used to animate one or more objects at once.
GUIObjects Only Functions:
SimpleTween:UIButton(Button: GuiObject, Callback: function)
SimpleTween:UIPosition(Object: GuiObject, EndPosition: UDim2, Duration: number, Callback: function)
SimpleTween:UISize(Object: GuiObject, EndSize: UDim2, Duration: number, Callback: function)
SimpleTween:UISizeAndPosition(Object: GuiObject, EndSize: UDim2, EndPosition: UDim2, Duration: number, Callback: function)
All Objects Functions:
SimpleTween:SingleTween(Object: Instance, Properties: table, Duration: number, Callback: function)
SimpleTween:MultipleTween(Objects: table, Properties: table, Duration: number, Callback: function)
All Objects Functions with Custom TweenInfo
SimpleTween:CustomSingleTween(Object: Instance, Properties: table, AnimateInfo: TweenInfo, Callback: function)
SimpleTween:CustomMultipleTween(Objects: table, Properties: table, AnimateInfo: TweenInfo, Callback: function)
Control Functions:
SimpleTween:GetTweens() -- Returns a table of available tweens.
SimpleTween:PauseTweens(Callback: function)
SimpleTween:ResumeTweens(Callback: function)
SimpleTween:CancelTweens(Callback: function)
Other Functions:
SimpleTween:GetValue(Alpha: number, EasingStyle: Enum.EasingStyle, EasingDirection: Enum.EasingDirection) -- Does the same thing as TweenService:GetValue()
Usage example and a simple comparison versus TweenService:
-- SimpleTween Usage example:
local SimpleTween = require(game.ReplicatedStorage:WaitForChild("SimpleTween"))
local function Callback()
print("Hello, World!")
end
SimpleTween:SingleTween(workspace.Part, {Transparency = 1}, 5, Callback)
-- Object, Properties Table, Duration, Callback function
VS
-- TweenService Usage example:
local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(
5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local function Callback()
print("Hello, World!")
end
local Tween = TweenService:Create(workspace.Parent, TweenInformation, {Transparency = 1})
Tween.Completed:Connect(Callback)
The callback function is optional.
As you can see from those examples, SimpleTween is much simpler and requires less code than TweenService.
Using TweenService, especially in more complex projects isn’t practical and wastes time especially when dealing with multiple tweens with different durations.
Update 07/12/23:
- Fixed
:MultipleTween()
and:CustomMultipleTween()
callback function. - Added
:GetTweens()
function. - Added
:PauseTweens()
function. - Added
:ResumeTweens()
function. - Added
:CancelTweens()
function.
Update 12/01/24:
- Added a feature that removes invalid properties.
- Added
:GetValue()
function. - Improved efficiency.