How to modify speed of modified default roblox animations?

In my game, I have a parkour system where you gain speed by running for a while. However, the walk animations are just overwritten roblox walk animations.

Here’s the script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)

	local hum = char:WaitForChild("Humanoid")
		local hrp = char:WaitForChild("HumanoidRootPart")
		local anims = char:WaitForChild("Animate")
		
		anims.walk.WalkAnim.AnimationId = "rbxassetid://74947900635575"
		anims.jump.JumpAnim.AnimationId = "rbxassetid://133746227608901"
		anims.fall.FallAnim.AnimationId = "rbxassetid://131422754475209"
end)

Because these are “animation” objects, and not “AnimationClip” objects, I can’t use the :AdjustSpeed() method on them. I don’t exactly know what to do, and I can’t seem to find another post about this specific issue in my case.

You can only adjustspeed on animation tracks rather then the animation instance. There is this built in function for the animator instance you can use by getting current animations playing.

--> Services
local players = game:GetService("Players")

--> Variables
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") :: Humanoid
local animator = humanoid.Animator

---------------------------------------------------------------

local function SetAnimationSpeed(Animename: string, speed: number) : AnimationTrack
	for index : number, animation : AnimationTrack in animator:GetPlayingAnimationTracks() do
		if animation.Length > 0 and string.match(tostring(animation), Animename) then
			animation:AdjustSpeed(speed)
			return animation
		end
	end
end

--> Events
humanoid.Running:Connect(function(speed: number)
	local animation = SetAnimationSpeed("RunAnim", 5) -- Animation Name and speed to set the animation speed
	print(speed, animation)
end)

Note that you can do more events other than then the humanoid running like humanoid states.

1 Like

Okay, i’ll make sure to try out this method, and tell you what happens.