Running animation doesn't play when i jump

So I made a running script and it’s pretty good but my problem is that when i press shift to run then jump(press space) the running animation just doesn’t play! Does anyone know any solution for this. here is my script :

--Variables --

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Properties = {FieldOfView = 80} --Fov
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, 
Enum.EasingDirection.InOut) --Tween
local T = 
game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, Info, 
Properties)
local rProperties = {FieldOfView = 70} --DefaultFov
local rInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, 
Enum.EasingDirection.InOut) --Tween
local rT = 
game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, rInfo, 
rProperties)
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")


local camerabobcf = CFrame.new()
local cam = workspace.CurrentCamera
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
local UserInputService = game:GetService("UserInputService")



local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6891970873"

local RunAnim = humanoid:LoadAnimation(Animation)
local UserInputService = game:GetService("UserInputService")

-- Detect keys pressed function --

local function isKeyPressed(input)
local keysPressed = UserInputService:GetKeysPressed()
for _, key in ipairs(keysPressed) do
	if key.KeyCode == input then
		return true
	end
end
return false
end


-- The input began --

UserInputService.InputBegan:Connect(function(inputObject, gameProcessedEvent)



if isKeyPressed(Enum.KeyCode.LeftShift ) and isKeyPressed(Enum.KeyCode.W ) then
	
		humanoid.WalkSpeed = 30
		T:Play()
		RunAnim:Play()
	
	elseif (isKeyPressed(Enum.KeyCode.W ) and isKeyPressed(Enum.KeyCode.A)) then 
	humanoid.WalkSpeed = 16
	rT:Play()
	RunAnim:Stop()


	
end

end)


-- The input ended --

UserInputService.InputEnded:Connect(function(inputObject, gameProcessedEvent)
		if inputObject.KeyCode == Enum.KeyCode.LeftShift or inputObject.KeyCode == Enum.KeyCode.W then 
			player.Character.Humanoid.WalkSpeed = 16
			rT:Play()
	        RunAnim:Stop()


		end
	end)
1 Like

You need to change the default jump animation i guess

what ? No i’m meaning that when i’m running and press jump it jus cancels out the running animation and plays the walking one instead even when i’m holding shift but when i let shift go then press it again it goes back to normal

1 Like

Maybe you could try check if humanoid is jumping then resume the animation…I guess??

It will cancel out the running animation since the state of the humanoid is changed to ‘Jumping’ and a new animation is played. To tackle this problem. You’ll have to check when a player jumps and then play the running animation along with the sprinting script that you have.

2 Likes

how can i check when a player jumps?

You can use this

Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
    print("Jumped!")
end)
1 Like

Ok thx , i’ll do an attempt to see if it works!

1 Like