How to update a tween while its playing

Details: Im trying to update how fast a tween plays while its playing after a number value in replicated storage changes its value

I tried multiple ways and so far nothing worked.

i did research of this kind of question, but the property i need to change is the speed of the tween

This is the code i use right now, i removed any tween updating code cuz none of them work

local tweenS = game:GetService("TweenService")

local timeVal = game.ReplicatedStorage.Time
local originPos = script.Parent.Position

local goal = {}
goal.Position = Vector3.new(0, 10, 0)

local tweenInfo = TweenInfo.new(timeVal.Value, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)

local tween = tweenS:Create(script.Parent, tweenInfo, goal)

tween:Play()

You do not. Instead you create a new tween to overwrite the old.

1 Like

Well unfortunately this will not work for me. Let me explain in a simple long form
Lets say we have 3 points, 1 at bottom, 2 in middle and 3 at top.
We define a tween that makes movement between point 1 and point 3
However when i update the tween while its playing, the tween will start making movement between point 2 and point 3.
Replicating this issue turns into the issue i have with the tween from the post
I need a different solution

Literally. We need keyframe UI animations.

It’s a bit hacky, but try to fork BoatTween (in community resources) to call a function each time it needs data. This way you could do something like this:

local BoatTween = require(anywhere)

local CubicBezierFunction = "EaseOutExpo"
local Goal = {
    Position = WHatever you want
}
local Time = 5

local function retriever()
    return {CubicBezierFunction, Goal, Time}
end

BoatTween:Create(AnyObject, retriever)

--change the animations bezier function after 2 seconds of running
--this works because the forked BoatTween module calls the retriever function
    --to get data each time it needs it
task.wait(2)
CubicBezierFunction = "EaseInExpo"

Im not sure what this script does and it doesnt really seem like what i need. Although i think the BoatTween will come inhandy.
Im just gonna give more details about what i need:
I basically need to change the speed of a tween while its playing after i change a number value in replicated storage.

It changes the data of a tween (speed, goal, easing like quint, linear). This changes the speed based on your objects value:

local BoatTween = require(anywhere)

local Object = game:GetService("ReplicatedStorage").Object

local CubicBezierFunction = "EaseOutExpo"
local Goal = {
    Position = WHatever you want
}
local Time = Object.Value

local function retriever()
    return {CubicBezierFunction, Goal, Time}
end

BoatTween:Create(AnyObject, retriever)

Object:GetPropertyChangedSignal("Value"):Connect(function()
    Time = Object.Value
end)
1 Like

This code might work
However if we are not using variables, how should i play the tween or am i not understanding correctly

Just BoatTween:Create(...).Play(). The code automatically updates the time based on the NumberValue. Just remember, you’d need to fork the module to provide this functionality.

Ok i tried running your code and changing tween time doesnt work.
Now when changing the time from the GetPropertyChangedSignal event, does the time relate to the defined variable, or the variable from the boat:Create.
Just gonna note that i had to avoid using the retriever function because when using it, the tween does not play for some reason

It won’t, you have to make a forked module for it to work. Plus, the retriever function is the only way I think without using external modules to change tween data while an object is animating.

It may be of use to control speed using cubic-bezier curves instead. Check out https://easings.co/ to test cubic-bezier animations.

You cannot, A suggestion is to use Runservice instead, as even for a solution to this would probably be less effective anyways.