Animation speed not changing

local BasicCombat = script.Parent
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local M1 = ReplicatedStorage.RemoteEvents.Combat.M1
local M2 = ReplicatedStorage.RemoteEvents.Combat.M2

local M1Anim1 = ReplicatedStorage.Animations.Styles.Basic.M1Anim1
local M1Anim2 = ReplicatedStorage.Animations.Styles.Basic.M1Anim2
local M1Anim3 = ReplicatedStorage.Animations.Styles.Basic.M1Anim3
local M1Anim4 = ReplicatedStorage.Animations.Styles.Basic.M1Anim4
local M1Anim5 = ReplicatedStorage.Animations.Styles.Basic.M1Anim5
local M1Anim6 = ReplicatedStorage.Animations.Styles.Basic.M1Anim6

BasicCombat.Equipped:Connect(function(mouse)
	local Idleanim = ReplicatedStorage.Animations.Styles.Basic.Idle -- make seperate tool for every style
	local Idleanimtrack = player.Character.Humanoid:LoadAnimation(Idleanim)
	local Walkanim = ReplicatedStorage.Animations.WalkLegsOnly
	local Walkanimtrack = player.Character.Humanoid:LoadAnimation(Walkanim)
	
	Idleanimtrack:Play()
	player.Character.Humanoid.Running:Connect(function(speed)
		if speed > 0 then
			Walkanimtrack:Play()
		elseif speed == 0 then
			Walkanimtrack:Stop()
		end
	end)
	
	local AnimationPlaying = false
	mouse.Button1Down:Connect(function()
		local number = math.random(1,6)
		
		if number == 1 then
			local M1AnimTrack1 = player.Character.Humanoid:LoadAnimation(M1Anim1)
			M1AnimTrack1:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack1:Play()
					M1AnimTrack1.Stopped:wait()
					AnimationPlaying = false
				end
		elseif number == 2 then
			local M1AnimTrack2 = player.Character.Humanoid:LoadAnimation(M1Anim2)
			M1AnimTrack2:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack2:Play()
					M1AnimTrack2.Stopped:wait()
					AnimationPlaying = false
				end
		elseif number == 3 then
			local M1AnimTrack3 = player.Character.Humanoid:LoadAnimation(M1Anim3)
			M1AnimTrack3:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack3:Play()
					M1AnimTrack3.Stopped:wait()
					AnimationPlaying = false
				end
		elseif number == 4 then
			local M1AnimTrack4 = player.Character.Humanoid:LoadAnimation(M1Anim4)
			M1AnimTrack4:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack4:Play()
					M1AnimTrack4.Stopped:wait()
					AnimationPlaying = false
				end
		elseif number == 5 then
			local M1AnimTrack5 = player.Character.Humanoid:LoadAnimation(M1Anim5)
			M1AnimTrack5:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack5:Play()
					M1AnimTrack5.Stopped:wait()
					AnimationPlaying = false
				end
		elseif number == 6 then
			local M1AnimTrack6 = player.Character.Humanoid:LoadAnimation(M1Anim6)
			M1AnimTrack6:AdjustSpeed(2)
				if AnimationPlaying == false then
					AnimationPlaying = true
					M1:FireServer()
					M1AnimTrack6:Play()
					M1AnimTrack6.Stopped:wait()
					AnimationPlaying = false
				end	
			end
	end)
	
	mouse.Button2Down:Connect(function()

	end)
	
	BasicCombat.Unequipped:Connect(function()
		Idleanimtrack:Stop()
	end)
end)

i tried to set the speed for every track using M1AnimTrack5:AdjustSpeed(2) but it dosnt work

1 Like

:AdjustSpeed(n) is for adjusting speed of an animation that is already playing

When you call :Play() on the track, you can pass 3 arguments fadeTime, weight, speed.

These arguments, if not provided, default to:

fadeTime = 0.1
weight = 1
speed = 1

These default values will override a speed set via :AdjustSpeed(), hence your animation plays at the normal speed.

So calling anim:Play(0.1, 1, 2) would play the animation twice as fast, leaving the other properties the same.

You can read up more on :Play() here

3 Likes