GetDescendants() for loop ignores some classes

When I try to iterate through every descendant of a given character, it works fine with classes like BasePart, Attachment, Motor6D and Decals, but ignores classes like Accessory, Shirt, Pants, SpecialMesh etc. Even though the GetDescendants() function works fine

local descendants = char:GetDescendants()
print(descendants) --Prints all descendants
for _, x in descendants do
	print(x) --Doesn't print some descendants
end

Same issue with GetChildren()
I don’t run the code above right after the game starts so everything is supposed to be loaded

Try using

for _, x in pairs(char:GetDescendants()) do
	print(x)
end

and tell me what happens

Unfortunately, gives the same result

Do you know which Instances are being left out specifically? (nvm i just saw)

Can you show a screenshot of the output after running the loop

Will they be detected if you use x.Name?

Things like Shirt, Pants etc. might try returning their value, which is probably nil if you work on a Rig

Made it print x.Name, still gets ignored

Have you tried this yet? (minimum chars)

I haven’t scripted or used the devforum in ages but I think this belongs in the Bug Reports and isnt really your fault because getdescendants should return everything. No matter what it is.

Maybe you can try doing this in a new baseplate? Other than that I don’t see an issue on your side.

2 Likes

Yeah, tried it in a new place and it worked fine

Seems like that problem occurs only in a single script, so I’ll use the other one for this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.