SimpleTween (TweenService Module)

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.

Get SimpleTween Module

4 Likes

Honestly this module seems pretty useless just because of the fact that it is a wrapper for an already made solution aka. “TweenService”. I would recommend you make a custom Tweening module that includes more easing styles so it will be more useful to people.

The final verdict is I think it is perfectly fine to advertise added efficiency but I think that it is important to also provide some sort of value in how useful this can be to developers. Overall I do like the inclusion on the callback argument in the functions so maybe I can see a small subset of people that will use this. In general keep up the work and happy developing.

Usefulness: 1/10
convenience: 6/10
Total Value: 7/20

4 Likes

Yeah, but my way is shorter than yours with your module:

local t = game.TweenService:Create(workspace.Part, TweenInfo.new(5, Enum.EasingStyle.Linear), {Transparency = 1})
t:Play()
t.Completed:Connect(function()
    print("hi")
end)

To be honest, all new scripters will get the idea of making a module and releasing it to the public, even if it’s not too useful. If that’s what your doing, then you are on the right path to being a great scripter! Keep learning and having fun.

3 Likes

While some people may say this isn’t useful, I am the WORST at tweening so this could actually save me time. Thanks.

2 Likes

It is not directly useful but it is very efficient, especially with the group tween function. So yeah you might want to use it.

1 Like

In general, though I just recommend that you do learn Tweening yourself because I feel like modules such as this one hinder personal growth and development for newer scripters such as you I presume.

I’m not new to scripting, but I just lack the ability to learn stuff easily. It takes me a while to actually get anything done in most scenarios. I can just try to dissect this module to find out what anything means.

I have used tweening before and I did attempt to find out what it can do but overall I feel as if it isn’t easy to actually get to work. Once I can manage to make that initial tween, everything is smooth-sailing from there.

1 Like

Good to know, But I really do recommend that you try tweening on your own without the help of this module as it will greatly help you succeed and create better games. Another recommendation is you can use TweenService:GetValue() in “RunService” and then make the alpha equal to the result of the aforementioned function and put this aforementioned alpha in a lerp function and get a pretty nice tween effect just using a simple lerp function. And I am so sorry for assuming that you are new, I just assumed you were new cause most people have used “TweenService” in some capacity.

Example:

local alpha = TweenService:GetValue(alpha: number, easingStyle, easingDirection)
randomVec = randomVec:Lerp(vector3.new(0,1,0), alpha)

Well, that is not the case with more complex things such as tweening multiple objects at once.

And No. Your code isn’t shorter:

My code is shorter but the way I wrote it seems longer.
image

A compact version of my code:

require(15560681898):SingleTween(workspace.Part, {Transparency = 1}, 5, function()
    print("hi")
end) 

Thanks for your motivation.

1 Like
function Tween(...)
	return game:GetService("TweenService"):Create(...)
end

local t = Tween(game.Lighting, TweenInfo.new(2), {Brightness = 10})
t:Play()
t.Completed:Once(function()
	print("Hi")
end)

-- or just by itself

function Tween(...)
	return game:GetService("TweenService"):Create(...)
end

Tween(game.Lighting, TweenInfo.new(2), {Brightness = 10}):Play()

1 Like

Just a note, incase you don’t know:

Requiring an asset id takes time, and is for the most part insecure. It’s better to promote your module by asking the developer to directly place it in their game. This way, they can read the code, and it will run instantly. It’s more secure because it won’t autoupdate. Autoupdating allows external developers to insert viruses. :fearful:

1 Like

Yeah I know I just did that to make my code shorter.

Also Requiring an AssetID won’t work on a client script.