Dividing two values outputs 0

Calculating the speed of the animation returns it as 0 the first time I call the function. But when I call the function a second time it returns the correct value.

local ReloadAnim = tool.Handle.ReloadAnim
			local reloadTrack:Animation=game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(ReloadAnim)
			
			local calculatedSpeed = reloadTrack.Length/reloadSpeed.Value
			print("p",calculatedSpeed)
			reloadTrack:Play()
			reloadTrack:AdjustSpeed(calculatedSpeed)

The first time I call the function and adjust the speed, the animation breaks because I try adjusting it with 0. But the 0 also breaks my idle animation. But when I call the function for a second time the reload animation has been adjusted successfully, while the idle animation is still broken.

I don’t have any clue why the function doesn’t work the first time I call it.
I appreciate any help I can get!

When loading an animation, it is well loading. it’s length could be 0 so your issue is because the animationTrack length is 0 and 0/something = 0. To fix this you could add this in your code

repeat
	task.wait()
until reloadTrack.Length > 0
1 Like