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

Is it possible to count children in a script?

How would you use a script to count children in let's say Workspace?

2 answers

✓ Accepted answer

Of course.

We can get the list of children of the workspace simply:

local children = workspace:GetChildren();

Since children is a table, we can get its length using the # operator:

local children = workspace:GetChildren();
local numberOfChildren = #children;
-- How many things are children,
-- the length of the list of children

Well, you'd use getchildren, which returns a table.

NumberOfChildren = #game.Workspace:GetChildren()

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