animationTrack:AdjustSpeed() not working

Howdy!

I’ve been debugging and trying to fix this issue for a whole day now, but it seems like nothing works.
I am trying to make an animation play with a certain speed depending on how long the player has pressed the left mouse button. The animation is created on the server side and gets fired whenever the player releases the left mouse button. I have tried testing the same code on the client, but nothing works. Whenever the animation starts, it pauses at the starting point of the animation and freezes. If the server code is firing again, the animation resets and only plays the very last part of the animation. As soon as I remove the :AdjustSpeed() line of the code, everything works.

Here’s my server sided code:

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=04761271923"
local animationTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
animationTrack:Play()
local speed = animationTrack.Length/timeDrag
animationTrack:AdjustSpeed(speed)

What is the timeDrag variable set to?

timeDrag is the time the player moves his mouse around before releasing left mouse button

Are you sure it isn’t negative, 0, or nil?

1 Like

instead of using :AdjustSpeed try it only using :Play

play has a third argument that does the same thing :AdjustSpeed should do
your code would change to:

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=04761271923"
local animationTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
local speed = animationTrack.Length/timeDrag
animationTrack:Play(nil, nil, speed)
2 Likes

It is not, I just checked :slight_smile: However the values are close to 0 (for instance 0.02)

I’ve tried that too, same result :confused:

Aaaah it seems like there is something wrong with the timeDrag variable… it does not calculate correctly…

Whoops, the issue was resolved! The problem was lying in the calculation of timeDrag. I am closing this thread now :sweat_smile:

Thank you for your kind help though :slight_smile:

1 Like