Adding a task.wait(0.02) on a for i,v do alternatives

Hi if i wanted to not make IT instant on ‘‘for i,v do’’ functions, so instead it waits 0.02 and does it, BUT somehow it takes 26 seconds or longer to even get 4 parts positions, WITH A WAIT of (0.02), the reason why i wanna add it is for performance. Am i using it wrongly?

What exactly are you even trying to do

Please post the script because we can’t help you without knowing exactly how you’re attempting this.

Sound like 0.02 is getting called many times in the for next loop.

task.wait(2)
for i = 1, 10 do -- whatever it is
	-- rest of your loop code
end

Let’s say, that the frame in wait() depends on your computer. If it is low-end, the frame can be higher than 0.1;

Generating path rapidly in a huge folder space.

THATS not what i meant… I meant like putting the wait INSIDE of the for i,v do, its supposed to fix performance at all costs.

Now my A*Star pathfinding uses those ‘‘for i,v do’’ to sort out neighboring nodes and generate a smooth path, BUT if i put wait on it. it will just take like forever, even with 3 nodes it will take 2 minutes to load in the path.

for i = 1, 10 do -- whatever it is

task.wait(0.03)
end

Something like this… i meant.

if i % 200 == 0 then task.wait() end
1 Like

that will technically not work i think.