I am wondering how I can figure out a math equation to create a smooth transition with any number I choose for the max_Sprint. The issue is that the tweenService plays my tween too quickly before the Current_Sprint can count down. Therefore, it does not create a non-stop smooth movement from side to side. It moves, then stops, and then moves again.
local Max_Sprint = 10
local current_Sprint = Max_Sprint --(HERE)
local Bar = script.Parent
local goal = {} --Used for tween service.
local tweenInfo;
local tween;
while true do
wait()
if current_Sprint >= 0 then
wait(0.1) --(HERE)
current_Sprint = current_Sprint - 1 --(HERE)
goal = {} --Used for tween service.
goal.Size = UDim2.new((current_Sprint/Max_Sprint), 0, Bar.Size.Y.Scale, 0)
tweenInfo = TweenInfo.new(0.1) --(HERE)
tween = tweenService:Create(Bar, tweenInfo, goal) --Create a smooth transition.
tween:Play()
else
break;
end
end
Is there some kind of math equation I can use to make it so the bar will smoothly and steadily go from side to side with any max number I choose? I placed comments that say “HERE” for where I think the issue persists. The timing of all of it is wrong and must correspond to each other thus why I am wondering if there is some equation I can use to automatically set that stuff based on the max number that I chose for max sprint.