I have this run animation and it’s a simple left shift to sprint but whenever the player is idling or jumping while holding left shift the animation still plays. I want to know how I can update to script to detect idling and jumping so that if the play jumps it plays the jump animation instead and if idling it will play the idle animation. Here is the script that I currently have:
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 35 --run speed
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://15708472541'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim.Priority = Enum.AnimationPriority.Movement
PlayAnim:Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16 --default walk speed
PlayAnim:Stop()
end
end)