DJ-Weirdo

Custom Character Walk Script

Jun 20th, 2021
1,841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1.  
  2. -- Very basic walking animation script by GnomeCode
  3. local character = script.Parent --Gets character
  4. local humanoid = character:WaitForChild("Humanoid") --Gets humanoid
  5.  
  6. -- Remeber to select the animtion object and set the id to your own!
  7. local walkAnim = script:WaitForChild("Walk") --Gets the walk animation for later use.
  8. local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim) --Gets the variable for the animation using the animation instance's ID and the humanoid
  9.  
  10. humanoid.Running:Connect(function(speed) --Creates a function once the character runs.
  11. if speed > 0 then --Plays the animation if the players speed is over 0.
  12. if not walkAnimTrack.IsPlaying then --Plays the track if it isn't playing already.
  13. walkAnimTrack:Play()
  14. end
  15. else --Stops the walk track if the player's speed is 0.
  16. if walkAnimTrack.IsPlaying then
  17. walkAnimTrack:Stop()
  18. end
  19. end
  20. end)
Add Comment
Please, Sign In to add comment