I was testing my game with a run animation script like this:

local Player = game.Players.LocalPlayer
	local Character = workspace:WaitForChild(Player.Name)
		local Humanoid = Character:WaitForChild('Humanoid')
		
local RunAnimation = Instance.new('Animation')
RunAnimation.AnimationId = 'rbxassetid://4586438451'
RAnimation = Humanoid:LoadAnimation(RunAnimation)

local ClimbAnimation = Instance.new("Animation")
ClimbAnimation.AnimationId = 'rbxassetid://04586591421'
CAnimation = Humanoid:LoadAnimation(ClimbAnimation)
Running = false

function Handler(BindName, InputState)
	if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then
		Running = true
		Humanoid.WalkSpeed = 24
	elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then
		Running = false
		if RAnimation.IsPlaying then
			RAnimation:Stop()
		end
		Humanoid.WalkSpeed = 12
	end
end

Humanoid.Running:connect(function(Speed)
	if Speed > 20 then
		RAnimation:Play()
	end
	if Speed < 15 then
		RAnimation:Stop()
	end
end)

Humanoid.Changed:connect(function()
	if Humanoid.Jump and RAnimation.IsPlaying then
		RAnimation:Stop()
	end
end)

game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.LeftShift)

It worked, but when the player jumps or climbs, the animation cancels and goes back to the standard run animation. There are no output errors or warnings, by the way.

I know this is vague and all, but I'm pretty sure there's some sort of Magnitude error.

Help please!

1 comment

0

You should use Humanoid.Jumping event instead of changed.