Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

can someone explain to me how tween service works?

Plz just don't tell me to look at the wiki I already looked and didn't really understand it

2 comments

1

it basically just moves something to another position smoothly, rather than "teleporting" it or using a for loop with CFrames

1

TweenService is the action of moving a part with a smooth transition https://m.youtube.com/watch?v=pKbQbCf9i90

1 answer

✓ Accepted answer

The service allows you to make smooth transitions between 2 things.. for instance, you can make a part move smoothly, make color transitions, etc.. Without tween service, making smooth movements of things is quite hard, the transition will be rocky, and just plainly unpleasant...

How the tween is played depends on the arguments that you pass to TweenInfo.new the argument list for TweenInfo.new new are as following:

1: time - how long the transition should take

2: style -how the transition will look

3: direction - how fast is should move depending on the timeframe of the transion

4: repeat - how many times the transition should repeat

5: reverses - whether the transition will reverse to the original position

6: delay - how long it should wait before the transition starts playing

once you create a TweenInfo object, you then need to define - in a table- which properties should be transitioned in the tween, for instance if you want a part to move to a new position, you would put a property named Position in the table, and give it the vector3 of where u want it to end up...

like this: properties = {Position = Vector3.new(20,20,20), Size = Vector3.new(20,40,10)} this tells the tween to change the position of the part to Vector3.new(20,20,20), and its Size to Vector3.new(20,40,10);

once you have that defined, you then need to pass the Object that you want to the transformations to happen to, the tweenInfo, and the properties to TweenService:Create.. which will return another object called a "TweenBase", on which you can call the Play() method on to start playing the animation..

like this:

tweenBase = TweenService:Create(object, tweenInfo, properties);
tweenBase:Play() --plays the animation

here are helpful videos and links:

EggBot;

AlvinBlox;

developer hub;

the Create Method

This discussion is preserved as it was. New answers, comments, and votes are closed.