How do I have an animation be able to play if left shift is held down and the character is running?
I have an animation in which I want it to play when the player holds down left shift and ONLY when they are running. If they are holding it down and they jump, fall, or have any other movement different from running then the animation will end and it will play the animations I have for falling, jumping, and so on. I did make it so if left shift is held down the animation plays, but I can't get it so that the animation can only play when the player is running. Right now I have code put it for it to work when the player falls, and I tried it, but it didn't work. Here is my code.
local character = script.Parent
boostanim = character.Humanoid:LoadAnimation(character.BoostAnimation)
local humanoid = character:WaitForChild("Humanoid")
speed = character.Humanoid.WalkSpeed
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if speed > 0 then
boostanim:Play()
humanoid.FallingDown:Connect(function(isActive) -- I tried to make it work with falling
input.KeyCode = input.KeyCode.BackSpace
end)
end
end)
game:GetService("UserInputService").InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
boostanim:Stop()
end
end)