Are there any limits to Instance:GetDescendants?

I want to do a search through my game.Workspace for all Instances whose name starts with “Proxy_”.

Historically I’ve done this with a utility function I have that maps a function over a sub-tree of the datamodel with a depth-first recursive search.

Is it better to use game.Workspace:GetDescendants()?

Pros:

  • probably faster
  • maybe a little cleaner
  • maybe a little easier to understand

Cons:

  • will this thing really return an array with 100k instances in it? Or is there some secret undocumented limit?
  • maybe uses more memory?

A function to map a lambda over a sub-tree of the datamodel would be a really useful built-in function.

2 Likes

Have you tried looking into CollectionService? Basically you can tag each object that has that name and loop through all of them without worrying if it is that or not.

6 Likes

There are no limits, but you want to use CollectionService with this tag editor!

You can also listen to items being added and removed, which is what I do with my binding system.

4 Likes

I’ve never heard of this service before.

The part where the tags don’t appear in Studio is kind of a bummer. I would want to create tags on my proxy objects as part of the authoring step.

Seems like a much better way to index into the datamodel though.

4 Likes