Slowing down a tween

I plan to make a part slow down based on the server speed. (1 is normal speed, 0 is completely stopped)
How would I make a tween move based on the speed? I don’t really have a definitive solution other than interpolation

More importantly, how would it be possible for me to change the speed mid tween so the part reacts based on that speed?

2 Likes

You could try something like this:

local tweenSpeed = 0.05
local currentTweenProgress = 0

repeat
     part.CFrame = StartPos:Lerp(EndPos, currentTweenProgress)
     currentTweenProgress = currentTweenProgress + tweenSpeed
     wait()
until currentTweenProgress >= 1

Changing the tweenSpeed variable should change the speed at which the part moves.

6 Likes

I’ve been retired for quite a while but if I recall correctly, you can set tween speed with TweenInfo

game:GetService("TweenService")

tweenInfo = TweenInfo.new([tweenTime],Enum.Direction.[In/Out/InOut],Enum.EasingStyle.[EasingStyle])

[TweenName] = TweenService:Create(tweenInfo,[Part],[PropertyName] = {[PropertyName]=[PropertyValue]})

…and then run the tween using [TweenName]:Play() in your script.

My memory can be a bit rusty since I retired from ROBLOX game development but you can configure the tween of how much time it takes in seconds to complete the tween with [tweenTime] in TweenInfo.new().

2 Likes