THIS MODULE HAS BEEN DEPRECATED AND SHOULD NOT BE USED. IT WILL NO LONGER RECIEVE UPDATES AND IS MOSTLY USELESS. I’VE LEFT THIS UP FOR ARCHIVING PURPOSES
I know there’s better alternatives but i decided to post this anyways. This module is just making tweening easier, and i think it can be very useful.
Module link: https://create.roblox.com/marketplace/asset/13822792949
Methods:
Tween: based on your current arguments it will create a tween.
Arguments:
-
Target (instance): your instance that you want to tween
-
Seconds (string/number): the amount of seconds the tween lasts
-
Goal (dictionary, like in regular tweens): it’s the property (Like
{Transparency = 1}
) -
Play (boolean, optional argument):
true or nil will automatically play the tween
false won’t do anything -
DestroyTween (boolean, optional argument):
true or nil will doCreatedTween.Completed:Once(function() CreatedTween:Destroy() end)
-
Easingstyle (Enum.EasingStyle, optional): your EasingStyle
-
EasingDirection (Enum.EasingDirection, optional): your EasingDirection
(if EasingDirection or EasingStyle are nil then it will default to Linear and Out)
MODELS ARE NOT SUPPORTED!
Here’s my code if you don’t want to open it in a place:
local TweenModule = {}
function TweenModule.Tween(Target, Seconds, Goal, Play, DestroyTween, Easingstyle, Easingdirection)
local TweenService = game:GetService("TweenService")
local TweenInfoVar = TweenInfo.new(Seconds,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
if Easingstyle ~= nil and Easingdirection ~= nil then
print(Easingstyle, Easingdirection)
local TweenInfoVar = TweenInfo.new(Seconds,
Easingstyle,
Easingdirection
)
elseif Easingstyle == 3 then --these are just my prefered tweening settings, nothing to see here lol
print(Easingstyle, Easingdirection)
local TweenInfoVar = TweenInfo.new(Seconds,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out
)
end
local CreatedTween = TweenService:Create(Target, TweenInfoVar, Goal)
if Play == true or Play == nil then
CreatedTween:Play()
elseif typeof(Play) ~= "boolean" and Play ~= nil then
error("Tween expects the last argument to be a boolean or nil, got ".. tostring(Play))
end
if DestroyTween == true or DestroyTween == nil then
CreatedTween.Completed:Once(function()
CreatedTween:Destroy()
end)
elseif DestroyTween == false then
TweenModule.CreatedTween = CreatedTween
elseif typeof(DestroyTween) == "boolean" and DestroyTween ~= nil then
error("Tween expects the last argument to be a boolean or nil, got ".. tostring(Play))
end
end
return TweenModule