AnimationTrack:AdjustSpeed() not working

So I am trying to adjust the speed of my animations but the moment I play the animation after adjusting it goes back to default speed. Here is the script:

local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local animator = humanoid:WaitForChild("Animator")

local skill1 = humanoid:LoadAnimation(script.skill1)

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.KeypadOne then
		skill1:AdjustSpeed(10)
		print(skill1.Speed) --Here it prints 10 as expected
		skill1:Play()
		print(skill1.Speed) --Now here it prints 1 meaning that it was set back to 1 instead of 10
		skill1.Stopped:Wait()
		print("Finished")
	end
end)

Why is this happening?

1 Like

AdjustSpeed() must be after :Play (), what’s the point of this? I do not know, is that, or when you use the script again, the speed goes back to the original.
And you must use Animator to load the animation.

34 Likes

You are right, I need to adjust speed after playing, I didn’t consider that because in the API itself it shows a function that plays after adjusting. Also, I loaded it to the humanoid just to check if it was the issue somehow.

6 Likes

I guess it’s a bug or that part needs to be updated, anyway, you’re welcome, happy to help ^ - ^

3 Likes

Yeah, they might have overlooked this because now I have to completely change my script to adjust only after playing the animation instead of adjusting it beforehand.

1 Like

Maybe they changed it in case they want to use animation again but with the same speed or another

1 Like

It’s rather odd to be honest, because it’s like setting a variable to another value then when you call it, it gets set back to the previous value. That wouldn’t make much sense.

Oh, so the “problem” is that :Play() has parameters itself, whenever you use it, it just sets the animation speed back to 1 as default.

Yes, but it’s still weird xd
It would look like this:

AnimationTrack:Play(0.1,1,10)
4 Likes

That’s a lot better than having to switch up the way I scripted this, I can just turn in the speed value and be at peace

1 Like