Need help with tween

  1. What do you want to achieve?
    I want to make a progressing bar that goes from left to right

  2. What is the issue?
    The progress bar works, it just doesn’t go in the right way. I’m using a for loop to move it and it feels impossible to make it move the other way. (it goes from right to left instead of left to right)

  3. What solutions have you tried so far?
    I’ve been checking on the dev forum, videos and even ask for help on discord and nothing helped

This is my code:

coroutine.wrap(function()
		local boostTime = 5
		local waitTime = 1
		
		while true do
			for i = currentBoost, 0, -1 do
				local BAR_CHANGE_SIZE = i / currentBoost
				playerBoostFrame.CurrencyText.Text = i
				
				tweenService:Create(playerBoostFrame.CurrentBoost, TweenInfo.new(waitTime), {Size = UDim2.new(BAR_CHANGE_SIZE, 0, 1, 0)}):Play()

				task.wait(waitTime)
				if i == 0 then
					for boost = boostTime, 0, -1 do
						playerBoostFrame.CurrencyText.Text = boost
						
						task.wait(waitTime)
					end
				end
			end
		end
	end)()
1 Like

for loops work like this

for index = startNumber, endNumber, addEachLoop do

since the index is counting down, you can multiply it by -1 to count up and then add the currentBoost so that it starts at 0

local BAR_CHANGE_SIZE = (currentBoost - i) / currentBoost

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.