Delay in Animation

Suppose my code looks something like:

local char = game.ReplicatedStorage.Dummy:Clone()
char.Parent = game.Workspace

local Animation = char.Humanoid.Animator:LoadAnimation(char.Rise)
wait(2)
repeat task.wait() until Animation.TimeLength > 0

Animation:Play()
wait()
char.HumanoidRootPart.CFrame = script.Parent.CharacterPointOne.CFrame

Now the problem here is that when I waited for the animation to load and everything, the animation doesn’t load instantly. For some reason, the Animation plays only half a second after the HumanoidRootPart is moved. If you can fix this issue, it would REALLY help.

Why is there a random wait between the animation playing and moving the HumanoidRootPart?

Are you sure there isn’t an issue with the animation?

Why are you using both wait and task.wait?

I am just waiting for an extra precaution.

There’s no point. Have you tried removing it?

The reason I added in the first place is because it didn’t work initially. Then I thought maybe the animation needs a little more time to play, then I can move it to the place.

Are you doing this in a LocalScript or a Script?

Also why is there a wait(2) at this line, you dont need to wait 2 seconds for :LoadAnimation() it usually only takes a few milliseconds, also, you already have something waiting for the AnimationTrack to load anyways, this wait is useless.

Please stop pointing at the the “unnecessary” waits. I just took the piece of the code working on a small scale and that wait(2) is to delay the upcoming functions.

Your question needs more context, consider providing a video of the problem and an explorer hierarchy of the script and instances involved

1 Like

Also, I still recommend you get rid of the wait. It effectively runs at 30 FPS and could be delaying the animation even longer than it already is.

And, have you tried waiting for the animation to end before moving the HumanoidRootPart? I can’t really tell what you’re trying to achieve.

btw you can use Animation.Stopped:Wait() to yield until the animation has finished.