Any way to gradually increment without using multiple for loops?

Solved it. I managed to get the recursion to work in two tries. I am ecstatic. Thank you all

For example:

for I = 1, 5 do wait()
print(‘lol’)
end
for I = 1, 10 do wait()
print(‘lol’)
end
for I = 1, 15 do wait()
print(‘lol’)
end

As much as possible, Id like to stick with the for loop as I’m positioning it according to the number of increments.
I’ve tried setting the initial loop to a high increment then checking if its greater/less than, but there has to be a better way. ty

local increment = 10

while wait() do

for i = 1,increment do 
wait()

if i == increment then
increment = increment + 5 
end

end

end

On mobile, not 100% sure if this’ll work, sorry

I had already thought of something similar, is there any way to do it with a for loop?

Or something along the lines. I don’t think that’s what im looking for friend. I’ve been experimenting with just random checks whether I is above or below a certain number, but I’m not sure whether this is the most efficient way of handling it.

Why don’t you make it a function, and then call it with providing the maximum value? Wouldn’t that help?

Example:

function countDown(maxVal)
    for i = maxVal, 1, -1 do
        print("Works!")
    end
end

countDown(5)
wait(5)
countDown(20)

Edit: forgot to attach the example.

Thats what I actually did initially. Basically, my script makes parts that forms a semi circle in front of my character and depending on the value it is set to, it readjusts the parts in a way so it still completes the semi circle, despite the set value. I want to be able to create three rows of the semi circle, but I want them to run simultaneously. I really don’t wanna have to use three coroutines to be able to run them together.
Thank you though!

1 Like

I was trying to make a recursive function for it that goes something like:

local loop = function(incr, msg, add, db)
	for i = 1, incr do
		if (i == incr) and (db == false) then
			loop(incr+add, msg, add, db)
		end
	end
        print(msg)
end;

But how would I redefine my parameters when I call it within the function?