I need help fixing my sprint script, it has an animation that plays when you hold the sprint keybind. I need help with stopping the animation when the player jumps, climbs, is doing the idle and swimming. Here is the current script, please alter it to fix these problems in the comments:
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 35
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://04942942286'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
end)

6 comments
Thanks, I really appreciate it.
i misread the op question, but what you posted isn't going to do what he asked.
How
it only checks the humanoid state once, and it doesn't stop the animation. there is too much going on there.
Ok and
and it won't work? you're downvoting my post because i downvoted yours. i only did it because your script is incorrect.