How Do I Tween The Speed of An Animation | Animation Support

This Is My Code:

task.wait(0.1)
M1Animation:AdjustSpeed(.4)
				
task.wait(0.1)
M1Animation:AdjustSpeed(.2)
				
task.wait(0.1)
M1Animation:AdjustSpeed(.4)
				
task.wait(0.1)
M1Animation:AdjustSpeed(.5)
				
task.wait(0.1)
M1Animation:AdjustSpeed(.6)
				
task.wait(0.1)
M1Animation:AdjustSpeed(.7)

Very NOT efficient or clean.

Any way to use TweenService to do this?

local TweenService = game:GetService("TweenService")
local M1Animation = -- reference to your animation track
local animationSpeed = Instance.new("NumberValue") -- Create a NumberValue to store the animation speed
animationSpeed.Value = 0.4 -- Starting speed

-- Tween Information
local tweenInfo = TweenInfo.new(
    1, -- Duration (time it takes to complete the tween)
    Enum.EasingStyle.Linear, -- EasingStyle (smooth linear change)
    Enum.EasingDirection.Out, -- EasingDirection (can be In, Out, or InOut)
    0, -- RepeatCount (no repeat)
    false, -- Reverses (no reverse)
    0 -- DelayTime (no delay)
)
-- Create the tween
local tween = TweenService:Create(animationSpeed, tweenInfo, {Value = 0.7}) -- Target speed
-- Adjust the animation speed whenever the NumberValue changes
animationSpeed.Changed:Connect(function(newSpeed)
    M1Animation:AdjustSpeed(newSpeed)
end)
tween:Play()

Can this do low to high speeds?

Like this snippet:

task.wait(0.1)
M1Animation:AdjustSpeed(.4) -- High
				
task.wait(0.1)
M1Animation:AdjustSpeed(.2) -- Low
				
task.wait(0.1)
M1Animation:AdjustSpeed(.4) -- High

Tweening can only follow set functions, you can see those here:

I would consider just baking what you’re doing with modifying the speeds into the animation itself.

I dont know how to animate :sweat_smile: Is there an easy way I could do what your saying?

create a numbervalue that has a parent in somewhere that you will probably not access (like replicatedstorage), tween the value, and every server tick, set the tween speed to the numbervalue’s value.

Thank you, ill try this when I get home.