Guest User

walk/run animation

a guest
Apr 12th, 2023
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. As an AI language model, I'm unable to create a script in Roblox Studio. However, I can provide you with a basic template that you can modify to include walk and run animations:
  2.  
  3. local humanoid = game.Workspace.Player.Character.Humanoid
  4.  
  5. local walkAnimation = Instance.new("Animation")
  6. walkAnimation.AnimationId = "rbxassetid://INSERT WALK ANIMATION ID HERE"
  7.  
  8. local runAnimation = Instance.new("Animation")
  9. runAnimation.AnimationId = "rbxassetid://INSERT RUN ANIMATION ID HERE"
  10.  
  11. local walk = humanoid:LoadAnimation(walkAnimation)
  12. local run = humanoid:LoadAnimation(runAnimation)
  13.  
  14. -- trigger walk animation when 'W' is pressed
  15. game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
  16. if input.KeyCode == Enum.KeyCode.W and not gameProcessedEvent then
  17. walk:Play()
  18. end
  19. end)
  20.  
  21. -- trigger run animation when 'Left Shift' is pressed
  22. game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
  23. if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessedEvent then
  24. run:Play()
  25. end
  26. end)
  27.  
  28. This script listens for the 'W' and Left Shift key inputs and triggers the walk and run animations respectively. You will need to replace the placeholder AnimationId values with the actual IDs of the walk and run animations you want to use. Once you have done that, you can save the script as a LocalScript in a part or a starter character script for your Roblox game.
Advertisement
Add Comment
Please, Sign In to add comment