How to turn "children" of an object into a table

The title may be a little bit confusing, not to mention how disturbing it sounds, but basically, I want all the children of, say, a folder in the workspace, to be turned into a table/array with text. I should probably provide an example:

so,

I have a folder, which contains objects with certain names.

And I want to have a table that is basically the same, but just the names.

So this:

image

gets turned into this:

someRandomTableName = {“CoolName”, “EvenCoolerName”, “Name”) (etc etc)

I hope you guys got what I meant!

The only important things are the contents, the name of the table is not important whatsoever.

1 Like

just use :GetChildren() on the instance, it will return all children as a table

4 Likes

do

local nameTable = {}

for _, v in pairs(Names:GetChildren()) do
    nameTable.insert(1,v.Name)
end
1 Like

:GetChildren() creates a normal table which you can add and remove instances from

1 Like

Oh, that’s true. I didn’t even think about that. Sometimes I wonder how I have gotten this far lol

you can just do

local names = workspace.Names:GetChildren()

for _, name in pairs (names) do
   --- code here
end

Spot on, easy and versatile.

Almost embarassing that I did not think of this myself.

1 Like

We’re always learning, happens to all of us. Nothing to be embarrassed about : )

2 Likes