TweenService is a one of those game services, so if you want to use it use the code "Game:GetService(TweenService)".
Using the service itself is a little complex at first but once you get used to it, it'll get pretty handy.
A tween is short for "inbetweening" because it can modify the animation between one position and another, or between whatever stuff you want. To use it, say TweenService:Create().
TweenService:Create accepts three variables. The first variable describes what object that you want to modify. For example, say this is script inside a brick and you want to modify that brick.
1 | local TS = Game:GetService( "TweenService" ) |
2 | local Part = script.Parent |
4 | local Tween = TS:Create(Part, nil , nil ) |
The second variable is a little complicated. It's describing what KIND of tweening you want it to do. It can be called by saying TweenInfo.new(). There are six statements inside this variable. The first is how long the Tween should last. The second is what kind of easing style the Tween should perform (eg should the animation slow down when it's coming to a stop, should the animation "bounce" a little, etc.) The third is which direction the tween will apply to (in or out), the fourth is how many times the tween should repeat, fifth is should it even repeat, and sixth is the delay in seconds between each tween. Below is an example if you're too lazy to read it.
01 | local TI = TweenInfo.new( |
04 | Enum.EasingStyle.Bounce, |
05 | Enum.EasingDirection.Out, |
The final variable inside the TweenCreate is what properties to tween. The variable itself is just an array of what properties to tween. You just need to state what property you want to modify, you don't need to do a root for it (ex. Part.Orientation, just do Orientation), but make sure that when you call the properties that you use the correct format for calling them (Size using Vector3, color using Color3/BrickColor, etc etc). Example if you're also too lazy lol.
3 | Orientation = CFrame.new( 5 , 1 , 2 ); |
4 | Size = Vector 3. new( 10 , 2 , 10 ); |
5 | Color = Color 3. fromRGB( 127 , 47 , 0 ) |
So after all of this nonsense and complex stuff, you can finally make your tween by compiling your three variables. Your part to modify, how you modify it, and what to modify. Additionally you need to do a :Play() on the tween, so don't forget that.
1 | Tween = TS:Create(Part, TI, TP) |
I'm sorry that this dang thing has to be so long, also if you're an expert in the field of tweening pleeeeassse correct me, but this is what I've learned so far.
Additionally if this is too confusing there's a good video on this, link is here. Definitely check it out. https://www.youtube.com/watch?v=qgGDwTn0zgo
Thanks!