Animation Speed while sprinting

Alright so i made a shift to sprint code and and i succeeded in it but the running animation looked a little too weird so i wanted to decrease the animation speed but i tried to search for solutions and none of them work.

This is the code i made right now. How do i improvise it to make the running animation as the default speed?

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local SprintSpeedMultiplier = 1.5
local OriginalWalkSpeed = Humanoid.WalkSpeed
local Sprinting = false

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed then
        if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
            Sprinting = true
            Humanoid.WalkSpeed = OriginalWalkSpeed * SprintSpeedMultiplier
        end
    end
end)

UserInputService.InputEnded:Connect(function(input, gameProcessed)
    if not gameProcessed then
        if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
            Sprinting = false
            Humanoid.WalkSpeed = OriginalWalkSpeed
        end
    end
end)

Then tweak your run speed or else use :AdjustSpeed(speed) on the loaded animation.

i dont quiet understand what u meant by that :sweat:

Most people would suggest that you use :AdjustSpeed() on the AnimationTrack. While they’re on the right path, said people don’t explain exactly how to utilize this.

AdjustSpeed:() must be called while the animation is already playing. The easiest way to do this is just by calling this immediately after you call :Play().

For an example,

Animation:Play()
Animation:AdjustSpeed(.5)
-- Animation will play at 50% of the original speed.

However, there’s an alternative solution and albeit more efficient way of going about this. In the :Play() function itself, you can feed it parameters to adjust the speed at the exact moment it’s called. :Play() has three separate parameters that you can play around with, but for now we’re focusing on the third one.

Animation:Play(.1, .1, 1) -- these are the default values called when :Play() is called.
Animation:Play(A, B, C) -- A is FadeTime, B is Weight & C is Speed, which is what you're looking for.
Animation:Play(.1,.1, .5) -- this will play your animation at 50% of the default speed while keeping the other default values for the Animation.

Hopefully I didn’t do too shabby of a job explaining this, but regardless I’d recommend you do some of your own reading of Roblox’s documentation, as it’s incredibly helpful. You can read about Roblox’s AnimationTrack and it’s methods & properties here!

1 Like
local SprintSpeedMultiplier = .4 -- to something lower based on your run anim speed

So if your animation if fast, we make the SprintSpeedMultiplier a higher number, else we make it a lower number.

reffer to @gelvinware for the other option

Also, just piquing my curiosity here, but where exactly are you storing the AnimationTrack? I don’t see it anywhere in the script being played.