Advertisement
jombo091

Shift to sprint with animation (ROBLOX)

Nov 16th, 2019
8,340
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. -- place in starter Gui also put what ever aniamtion you want in it (r15/r6)
  2.  
  3.  
  4. local Player = game.Players.LocalPlayer
  5. local Character = workspace:WaitForChild(Player.Name)
  6. local Humanoid = Character:WaitForChild('Humanoid')
  7.  
  8. local RunAnimation = Instance.new('Animation')
  9. RunAnimation.AnimationId = 'rbxassetid://1721906652'
  10. RAnimation = Humanoid:LoadAnimation(RunAnimation)
  11.  
  12. Running = false
  13.  
  14. function Handler(BindName, InputState)
  15. if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then
  16. Running = true
  17. Humanoid.WalkSpeed = 50
  18. elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then
  19. Running = false
  20. if RAnimation.IsPlaying then
  21. RAnimation:Stop()
  22. end
  23. Humanoid.WalkSpeed = 16
  24. end
  25. end
  26.  
  27. Humanoid.Running:connect(function(Speed)
  28. if Speed >= 10 and Running and not RAnimation.IsPlaying then
  29. RAnimation:Play()
  30. Humanoid.WalkSpeed = 50
  31. elseif Speed >= 10 and not Running and RAnimation.IsPlaying then
  32. RAnimation:Stop()
  33. Humanoid.WalkSpeed = 16
  34. elseif Speed < 10 and RAnimation.IsPlaying then
  35. RAnimation:Stop()
  36. Humanoid.WalkSpeed = 16
  37. end
  38. end)
  39.  
  40. Humanoid.Changed:connect(function()
  41. if Humanoid.Jump and RAnimation.IsPlaying then
  42. RAnimation:Stop()
  43. end
  44. end)
  45.  
  46. game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.LeftShift)
Advertisement
Comments
  • FankyTheFriend
    1 year (edited)
    # Lua 0.11 KB | 0 0
    1. -- Change line 5 to
    2. local Character = Player.Character or Player.CharacterAdded:Wait()
    3. --Hi from 2024 btw
Add Comment
Please, Sign In to add comment
Advertisement