Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Does tweens get erased when a new tween is applied to the same object?

Asked by
Dfzoz 489 Moderation Voter
4 years ago
Edited 4 years ago

I was creating a 2d grid movement system for my enemies AI. It moves by checking if the slot next to him is empty and then uses cframe to move. As it was too laggy to move with cframe in a wait() loop, I decided to make the enemy go to the empty slot instantly instead. For the animations, I used remoteevents for the client to know that when the enemy position changes it creates a tween for moving animation. But what would happen to my movement tween if it doesnt complete before the enemy moves and another tween starts? does the old tween just get destroyed or is there a possibility that it can bug/flick?

1 answer

Log in to vote
1
Answered by
RSASDSA 72
4 years ago
Edited 4 years ago

When a tween is played, it will stop other tweens that were played before it from modifying any property that it is modifying on the same object, but the other tweens will still modify properties that the new tween is not modifying.

For example, if a tween was played that made a part red while moving it down, and then another tween was played that moved the part left, the part would stop moving down, but still be turning red.

From the wiki:

Multiple tweens can be played on the same object at the same time, but they must not be animating the same property. If two tweens attempt to modify the same property, the initial tween will be cancelled and overwritten by the most recent tween (see examples).

( Tween )

Ad

Answer this question