Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sprinting animation works while not moving?

Asked by
kolenk 9
4 years ago

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)
0
You might want to add another keycode so that the animation only works if you are pressing an arrow key with it. StoryOfWhat -5 — 4y
0
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 Dfzoz 489 — 4y
0
not sure what you mean by that? kolenk 9 — 4y

Answer this question