Problem with Humanoid.Running

I am currently making a sprint script. but for some reason, when speed = 0. The animation doesn’t stop playing. Me disabling the animate script inside of the character has nothing to do with it.

hum.Running:Connect(function(speed)
	if speed == 0 and run then
		print(speed)
		
		if Track1 then
			Track1:Stop()
		end

		game.Players.LocalPlayer.Character.Animate.Disabled = false

		hum.WalkSpeed = 16

		local properties = {FieldOfView = DefaultFOV}
		local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
		local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
		T:Play()
	elseif run then
		print(speed)
		local now = tick()
		local difference = (now - lastTime)

		if difference <= 0.5 then

			game.Players.LocalPlayer.Character.Animate.Disabled = true

			run = true

			Track1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Animation)
			Track1:Play()

			hum.WalkSpeed = 20

			local properties = {FieldOfView = DefaultFOV + 15}
			local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
			local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
			T:Play()
		end
		lastTime = tick()
    end
end)

any output to suggest the problem?

Because the event won’t run when the player isn’t running so you’d have to find a new way to turn off the animation

1 Like

Nope, no output problems. I have checked.

No, that is not the problem the event name is quite misleading. It fires every time the player’s walkspeed changes.

print(speed)

When I print the speed, it will return with 0 if the player stops moving.