So I'm working on a script that can search models in the workspace however, I want to know if it is possible to find a model based on its children rather than its name.
Example:
I have two models named Model_A but one of them has a Part named Part1 and the other has Part2, How do I tell a script to find Part1 only or Part2 only and ignore the other.
(Also I'm keeping this all in one central script, so I don't want a script that is inside the Part and finds the parent)
https://gyazo.com/7e4e0472bfd894b9cc0045b618dcc650
You should use GetDescendants. This function gets everything (not children). So if you want to check every object in the service ,model or folder use GetDescendants
Here is example:
for index ,object in pairs(workspace:GetDescendants()) do if object:IsA("Part") then if object.Name == "Part1" or "Part2" then print(object.Name) end end end