Detect for loop end

I’m creating a plugin that adds custom textures to all selected parts. Basically the plugin loops through a table of parts (using for loops) and adds a texture. I would like to add a ChangeHistoryService waypoint when all the part textures have been created.

2 Likes

if it’s an array you can do something like this…

local tab = {}
local loopEnded = false

for i, v in ipairs(tab) do
 -- do stuff

 if i == #tab then
  loopEnded = true
 end
end
1 Like

Had to search for a while, but found it.
This video helped me out a LOT when I made my first plugin.

1 Like

The loop will yield the rest of the code till it finishes. You could just run your code after the loop.

for i = 1, 10 do
   -- code
end

-- loop ended
1 Like

Thanks for the responses but my problem wasn’t solved. It seems to be a problem with other thing and for loops aren’t involved in It.