Tweening animation speed?

I was wondering if it’s possible to tween animation speed (AdjustSpeed) like this:

TweenService:Create(Animation,TweenInfo.new(2),{AdjustSpeed(1.7)}) --Animation goes from 1 to 1.7 in two seconds.

AdjustSpeed() requires and is a number so it would make sense to tween it no?

Since the tween dictionary can’t just use built-in functions unless specified which property you’re working with, you may need to change the code to this:

TweenService:Create(Animation,TweenInfo.new(2),{AdjustSpeed = 1.7})
1 Like

You can do something like this

local TweenService =  game:GetService("TweenService")

local NumberValue = Instance.new("NumberValue")
NumberValue.Value = 1

local Tween = TweenService:Create(NumberValue, TweenInfo.new(2), {Value = 1.7})

local Connection = NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
	Animation:AdjustSpeed(NumberValue.Value)
end)

Tween:Play()

Tween.Completed:Once(function()
	Connection:Disconnect()
	NumberValue:Destroy()
end)

it works

1 Like

You don’t need to create a connection variable and disconnect it later if your destroying the instance anyways.

Wait it had speed omg I’m dumb sjjdkfkggkgkkdskkd

You might just search for that when you needed this

is there anyways to make this play (the AdjustSpeed function) everytime Humanoid.Running functions run? Do i just remove the Conneciton:Disconnect?

is this what you mean

local TweenService =  game:GetService("TweenService")

local Humanoid : Humanoid = nil
local Animation : AnimationTrack = nil

local LastConnections = {}

local function OnRunning()
	for i, Connection in ipairs(LastConnections) do
		Connection:Disconnect()
		table.remove(LastConnections, i)
	end
	
	local NumberValue = Instance.new("NumberValue")
	NumberValue.Value = 1
	
	local Tween = TweenService:Create(NumberValue, TweenInfo.new(2), {Value = 1.7})
	
	Animation:AdjustSpeed(NumberValue.Value)
	local Connection = NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
		Animation:AdjustSpeed(NumberValue.Value)
	end)
	
	Tween:Play()

	local EndConnection = Tween.Completed:Once(function()
		Connection:Disconnect()
		NumberValue:Destroy()
	end)
	
	table.insert(LastConnections, Connection)
	table.insert(LastConnections, EndConnection)
end

Humanoid.Running:Connect(OnRunning)
2 Likes
local Connection = NumberValue.Changed:Connect(function(Value)
	Animation:AdjustSpeed(Value)
end)

Use the Changed event/signal for value objects.

1 Like