Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Find Model Based on Children?

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

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.