Hello, I’m currently working on a control script that uses tweening for changing variables.
Currently, the tween does work when I’m tweening to a higher value, but when it’s set to a lower value, it drops to that lower value instantly, and not smoothly. So far, I haven’t been able to find a solution.
Here’s the script that I used for the tween.
local TweenStop = TS:Create(Line.BlueChair, TweenInfo.new(5, Enum.EasingStyle.Linear), {Value = 0})
Sounds like you want the speed to be constant regardless of the difference between values.
To do this:
Find the difference between the current value and the goal value then multiply that by a constant. (newValue - oldValue) * constantSpeed
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local numValue = script.TestValue
local speed = .5
local t = tick()
local oldValue = numValue.Value
local newValue = 0
local distance = (newValue - oldValue)
local tweenTime = speed * distance
local tween = TS:Create(numValue, TweenInfo.new(tweenTime), {Value = newValue})
tween:Play()
tween.Completed:Connect(function()
print("Completed in: "..tick()-t)
end)
I wrote this in a local script stored in StarterGui with a number value inside of it. It completes the tween in the same amount of time regardless of how far away the two values are from one another.