We do have :FindFirstChildOfClass() but It will only choose one... If I'm wrong please tell me. I want to know if there is a way to find all children from one class.
✓ ANSWER ACCEPTED
How to Find all Children of an Instance by Class?
2 answers
✓ Accepted answer
That I'm aware of, there is no built-in function to do it. The best way to get all children by a class is writing a function for it yourself, which is fairly simple!
Loop through the instance's children, check their class, if it matches the one you are looking for, then add it to a table. In the end, return the table.
It's fairly simple to write
local function getChildrenOfClass(instance, class)
-- table to hold the children
local children = {}
-- looping through the instance's children
for i,v in pairs(instance:GetChildren()) do
-- check if the child's class matches the one we're looking for
if(v.ClassName == class)) then
-- we add it to the table
table.insert(children, v)
end
end
-- we return the table, so that it can be used when calling the function
return children
end
Afterwards, you can call your function whenever needed, and access it!
To access it, you can do it in the same way that you would for FindFirstChildOfClass() !
-- This will allow you to use the children you've selected using the function
local childrenOfClass = getChildrenOfClass(model, "Part")
for i,v in pairs(childrenOfClass) do
print(v.Name) -- This would output the part's name, you can do anything else with it!
end
function GetChildrenOfClass(Instance, Class)
local ChildrenOfClass = {}
for _, Child in pairs(Instance:GetChildren()) do -- iterate through table returned by GetChildren
if Child.ClassName == Class then -- Check if ClassName matches Class Argument
table.insert(ChildrenOfClass, Child) -- insert into table
end
end
return ChildrenOfClass -- Return the table
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

13 comments
Im not a pro in scripting, so could you refer to the returned thing?
Yep! I'll edit my answer to also answer that!
Thanks!
Happy to help!
for the "local childrenOfClass = getChildrenOfClass(model, "Part")" when is say model, "Part" do w have to change it? If so, what should we change it to.
Model is your Instance, but I wanted to give a practical example. "Part" is the class type, could be anything. Script, MeshPart, ShirtGraphic, anything you would like!
Oh ok got it!
Hope that this helped, if you have any further questions, let me know!
It worked, thanks alot!
Wait, how do you make it create a clone of the stuff that it finds and put in a player?
Using :Clone() and parenting the cloned instance to the player; https://developer.roblox.com/en-us/api-reference/function/Instance/Clone
Do note that IsA will return true for any object that inherits that Class too
My bad, will edit to use .ClassName, ty!