Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a custom run animation for my sprint script?

Hi, I wanna know how to make a run animation for my game for when the player sprints, Note I used a YouTube video to help me.

Script: game:GetService("UserInputService").InputBegan:connect(function(input,gameprocesed)
 if input.KeyCode == Enum.KeyCode.LeftShift then
  for i = 1,16 do
   wait()
   game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView + 1.6
   game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed + 1
  end
 end
end)

game:GetService("UserInputService").InputEnded:connect(function(input,gameprocesed)
 if input.KeyCode == Enum.KeyCode.LeftShift then
  for i = 1,16 do
   wait()
   game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView - 1.6
   game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed - 1
  end
 end
end)

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:connect(function()
 game.Workspace.Camera.FieldOfView = 70
 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
 script.Disabled = true
end)

1 answer

What you want to know is how to implement animations on your code or how to actually create an animation?

If you want to create an animation there are plugins which can help you do that.

If you want to code so an animation plays when you run, you can test a game in roblox studio to find the 'Animate' localscript that is inside a character when it spawns. From what I remember, to play a walkanimation, that script checks if the humanoidstatetype is running and if its speed is higher then '0.75'. You could add a line to check if its speed is higher than the walking speed, and if it is, play the run animation, if not, check if its speed is higher than 0, and if it is, play a walk animation.

To know more about animations, check roblox API for Animation and AnimationTracks.

After you edit the character built in 'Animate' localscript to what you desire, copy and paste it inside the 'StarterCharacterScripts' inside 'StarterPlayer', as doing so will replace the default 'Animate' script with the one you put there and has the same name.

This discussion is preserved as it was. New answers, comments, and votes are closed.