Get the module Here
The other day I was trying to bulk tween an aspect ratio constraint and noticed there’s really no good way todo it currently. Thus I made varTween.
Currently in order to tween a variable you need to use an external value or make a runservice script and use tweenservice:GetValue(). This module basically works as a glorified wrapper to tween service that keeps track of values for you. I honestly made this for myself but figured alot of other people probably also have the same annoying headache. The module is pretty drop in with only two methods but gets the job done just fine.
Benefits to using varTween:
- Easy to implement
- You can access tweens across scripts
- works with numbers, strings, and tables
- Probably faster?
Example Usage
local varTween = require(game.ReplicatedStorage.varTween)
local TweenKey = varTween.TweenInit(200, 2, 5, {EasingStyle=Enum.EasingStyle.Exponential, EasingDirection=Enum.EasingDirection.Out, RepeatCount=0, Reverses=false, TweenDelay=0, AutoGarbageCollect=true, AutoGarbageCollectDelay=3})
--makes the tween and returns a tween key
game:GetService("RunService").RenderStepped:Connect(function()
print(TM.TweenRecall(TweenKey))
--you have to call .TweenRecall(Key) to get the new value and it works independently
--of framerate using time()
--Behavior: Number starts at 2 -> goes to 200 after 5 seconds -> waits 3 more seconds to garbage collect
--all params are optional and so is the starting value
end)
Documentation
Key[any but defaults to int] = module.TweenInit(
Goal [number, string, or table] (required),
Start [same type as goal] | defaults to one of the following: 0, “”, {}
TweenTime [number] (required),
Params (Optional):
{EasingStyle [Enum] | **defaults to quad**,
EasingDirection [Enum] | **Defaults to InOut**,
RepeatCount [int] | **defaults to 0**,
Reverses [bool] | **defaults to false**,
TweenDelay [number] | **defaults to 0**,
AutoGarbageCollect [bool] | **defaults to true**,
AutoGarbageCollectDelay [number] | **defaults to 0.2**
, OverrideKey [any] (Optional) | you can override an existing tween with this key
})
value = module.TweenRecall(Key)
return guide:
Table: returns a table going in order up to value
ex: {“val1”, “val2”, “val3”} and a 66% done tween:
{“val1”, “val2”}
(supports dictionaries)
String: basically works like string.sub but tweens
ex: “hello!” and a 50% done tween:
“hel”
Number: its just a number tween
ex: 10 and a 50% done tween:
5
Nil: means that tween was garbage collected
nil
Is this module useful:
- Yes
- No
0 voters