Locally looping a animation at the middle of it

Hey developers. I’m trying to loop a animation at 2 points of the middle of the animation, in a local script. For example: animation gets to 2.3 seconds, and it loops it back down to 0.6 seconds, and repeats this. This is what I have so far:

repeat
			talking:Play()
			repeat task.wait() until talking.TimePosition >= EndTalkLoop --Works fine
			talking.TimePosition = StartTalkLoop --Doesn't start it at here
until false

My issue is that the animation doesn’t start at the time I want it too (StartTalkLoop), but rather starts from 0. Is there any way I can fix it so it starts at 0.6 or any other time?

Much like Sound:Play(), AnimationTrack:Play() will set the time position, when called, to 0. You need to set the time position after calling AnimationTrack:Play().

1 Like

And correct me if I am wrong but that’s what I did (or atleast thought I did).

My first line calls the track with playing it

My second line waits until the track is 2/3 done (using variables)

And lastly the 3rd line calls the track to restart at 1/3 of the way (again with variables)

That’s not what you did.

First, you play the track (this sets TimePosition to 0). Then, you wait until the track is positioned after the “EndTalkLoop”. Next, you move the time position over to the start. Finally, you repeat this.

“You move the time position over to the start.” → “you play the track (this sets TimePosition to 0)”

Observe the order of events.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.