Why is my animation delayed

So basically I have a sprint animation and when I press shift it is meant to change the default running animation to my one. The problem is it take a couple of seconds to load the running animation and I don’t know why.
Problem:


(Edit: sorry I put the wrong video in I’ll fix it later)

script:

(By the way if you have any improvement for my script please share them, same for the animation.)

1 Like

Paste this above the KeyDown function:

local SprintAnimation = Instance.new("Animation")
SprintAnimation.AnimationId = "[your animation id]"
local SprintAnimationTrack = character.Humanoid:LoadAnimation(SprintAnimation)

And in the KeyDown function paste this in:

SprintAnimationTrack:Play()

And in the KeyUp function paste this in:

SprintAnimationTrack:Stop()

Hope I helped.

(If you’re having any trouble pasting this in, just send me the actual script as text so I can paste it in for you.)

Post Format Recommendations

The video you provided seems more like what you would expect your code to do, rather than actually showing the problem (playtesting).

Also, don’t use screenshots to send your code, because:

  1. It’s more difficult to copy the code for our own testing.
  2. Previews do work, but not all the time, like so:

    (clicking the seemingly broken photo does show the content, but it may not be obvious to some).

Copy your code and paste them between a pair of three grave accents (`), like so:

```
local function yourCode()
print(“here”)
end
```

The above should show up like this:

local function yourCode()
    print("here")
end

I’ve tested your code with a different animation (I believe animations can only be played by the publisher and in their games, meaning no one has access to any animations, with the exception of animations made by Roblox). Changing the animation links did nothing to replace the run animation.

It should be noted that you have to load the animation to the player’s Humanoid.Animator first before playing the animation. Changing the ID of the RunAnim is not sufficient, nor effective (the Animate has its own table of animation IDs).

You can try to copy the player’s Animate script and edit the values there, however, you have to adjust how fast the user must be running to play the run animation.

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