So basically Im trying to make a sprinting animation but if you're standing still and hold shift the animation plays even though you're not moving any help please?
uis = game:GetService("UserInputService")
plr = game.Players.LocalPlayer
character = game.Workspace:WaitForChild(plr.name)
Character = plr.Character
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift
then
character.Humanoid.WalkSpeed = 30
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://3726121052'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
if character.Humanoid.WalkSpeed == 0 then return else end
end)
uis.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift
then
PlayAnim:Stop()
character.Humanoid.WalkSpeed = 16
end
end)

3 comments
You might want to add another keycode so that the animation only works if you are pressing an arrow key with it.
Maybe add a humanoid.StateChanged to check if he is on a running state and then check if its holding LeftShift then the animation plays
not sure what you mean by that?