We use cookies on this site to enhance your user experience
Collapse Sidebar


Returns an array containing all of the Instance's descendants.

Running this function will collect every object descending from this Instance and return them in an array.

Note this function returns all descendants of the Instance, if only direct children are required use Instance/GetChildren instead.


Return Type Summary

An array containing the Instance's descendants.

Code Samples


GetDescendants is often used to do something to all the descendants that are a particular type of object. The code in this example uses GetDescendants and /Instance/IsA to find all of the parts in the workspace and turns them green.

local descendants = game.Workspace:GetDescendants()

-- Loop through all of the descendants of the Workspace. If a
-- BasePart is found, the code changes that parts color to green
for index, descendant in pairs(descendants) do
	if descendant:IsA("BasePart") then
		descendant.BrickColor = BrickColor.Green()