Animationtrack:Stop(3) waits 3 seconds, then fires

Hi, first post, please excuse any mistakes i make.

So, i’m making a script that tracks for how long a button is being pressed, and stops an animation using AnimationTrack:Stop() using that amount of time.

The problem is, it delays the animation from stopping for the amount of time that is being used.

For example:

I want the animation to stop, but i want it to take 3 seconds for it to stop.
So i use:

AnimationTrack:Stop(3)

But when i enter that, it waits 3 seconds, and after that it also takes 3 seconds to stop.
So it practically works but also doesn’t?

I don’t understand a bit of what i have to do to fix it. And it has been bothering me for a couple of days.

Here’s the relevant part of the script for reference:

local secondsheld = 0
local inputservice = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5055476251"
local animationtrack = char.Humanoid:LoadAnimation(animation)
animationtrack:Play()
inputservice.InputBegan:Connect(function(key)
 if key.KeyCode == Enum.KeyCode.W then
  repeat 
   wait(.1)
   secondsheld = secondsheld + .1
  until inputservice:IsKeyDown(Enum.KeyCode.W) == false or secondsheld >= 5
  animationtrack:Stop(secondsheld) --Part where it delays
 end
end)

If you have any further questions, please feel free to ask.

-Spectro

1 Like

why are you checking seconds held?
why not just do animationtrack:Stop() after the repeat loop?

Because i want the animation to stop for the same amount of seconds that the button was being held down. Sorry if it is too confusing

Have checked the output?

(30 chars)

The output doesn’t give any errors

Oooh! I see.
so you want it to take that amount of time to return to the natural pose?
huh, that is weird. as the animationtrack should fade out in the time according to the wiki.
sounds like an engine bug :thinking:

Exactly, i find it very strange aswell.

Isn’t it ironic, after making a post on the devforum stating my issue that i have been having struggles with for a couple days, i find the solution.

Sorry for being stupid y’all, though the time and effort people spent trying to help is appreciated!

Could you maybe share what the solution is so that others with the same problem know what you did to resolve your problem and can use that to help with their own systems?

I didn’t include this in the script cause i thought i changed it, but the animationtrack:play() had a weight attached to it so it was like animationtrack:Play(0,3,1)