Looping through thousands of parts

Hello there! I am currently working on a small project that would require a loop that has to go though thousands of parts and change certain values to them depending on the parts name. I’ve done a loop already however it takes a minute or so for it to complete it’s task. Is there an easier way to do this?


You can avoid looping through thousands of parts by tagging those special parts using collection services and getting those parts with the name with the :GetTagged function.

Can you give more specifics on what exactly you’re trying to do? That would help with thinking of a better solution.

So I’m currently generating an infinate library, first it generates the layout of the bookshelves by spreading out platforms. Then it generates the bookshelves, the books are the ones that take like 5-10 minutes to generate because the loop has to go though each book and change a book value inside of them (indicating the name). My question was how to generate those books faster.


Looping through thousand of parts is quite fast, generating them is not.
Generate the parts without parenting them into workspace, and when finished, parent them at once (e.g. parent them in a model without a parent, then parent the model into ws)

If the model already exists: make a clone, remove its parent (set to nil), change the part values within the clone, when done, replace the original model at once.

I forgot that they are locally generated into a model which holds about 20-30 books
which is patented into a folder in workspace

I still suggest the same.
If no other way, you can try to prepare changes in an array first, then set part values from the array, that can speed up a bit the process.

I wonder what kind of changes you can make that takes 5-10 minutes with 20-30 books, it shouldn’t take so long. Things that changes rendering the objects can slow down the process.