Jumping cd stopping run animation

whenever I press space with the jump cooldown active the run animation stops playing. why is this happening?

run script:

local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild('Humanoid')

local RunAnimation = Instance.new('Animation')
RunAnimation.AnimationId = 'rbxassetid://10198983764'
RAnimation = Humanoid:LoadAnimation(RunAnimation)

_G.RunningSpeed = 32

Running = false

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

Humanoid.Running:connect(function(Speed)
	if Speed >= 10 and Running and not RAnimation.IsPlaying then
		RAnimation:Play()
		RunningVar = _G.RunningSpeed
		Humanoid.WalkSpeed = RunningVar
	elseif Speed >= 10 and not Running and RAnimation.IsPlaying then
		RAnimation:Stop()
		Humanoid.WalkSpeed = 16
	elseif Speed < 10 and RAnimation.IsPlaying then
		RAnimation:Stop()
		Humanoid.WalkSpeed = 16
	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)

jump cd script:

local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Jumping then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
		wait(2)
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	end
end)
Humanoid.Changed:connect(function(property)
	if property == "Jump" and Humanoid.Jump and RAnimation.IsPlaying then
		RAnimation:Stop()
	end
end)

You may want to check if the property that changed was ‘Jump’, the ‘Changed’ event/signal will fire whenever any of the humanoid’s properties change.

1 Like

Thank you! For anyone who has the same problem, I changed my script to the following:

Humanoid.StateChanged:connect(function(old, new)
	if new == Enum.HumanoidStateType.Jumping and RAnimation.IsPlaying then
		RAnimation:Stop()
	end
end)
1 Like