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 get data in a table with :GetChildren?

I am starting to work on an installer plugin which would allow you to install any compatible game kit in to your game (using asset id's). But anyway I want to add a way for developers to add optional parts to the installation (I.e. points, developer products, and the like), and the only way I can tell what is available to install, is by knowing the children of my optional folder, by use of a table, and I need to know if this is possible using :GetChildren.

1 comment

1

GetChildren returns a table of all objects inside the model/folder. So a table is basically already one.

2 answers

✓ Accepted answer

Using :GetChildren() will return a table in itself.

1 comment

0

thanks

The product of :GetChildren() IS a table. If you put

print(workspace["Model"]:GetChildren())

in the command line, for example, it'll return "table: " followed by a serial number for the table.

If you want to utilize the table in some way, there are various ways you can check. Here's a couple of examples:

 for i,v in pairs(script:GetChildren()) do
 	if v ~= nil then return v end
 end
local children = script:GetChildren()
for a=1,#children do
	if children[a] ~= nil then return children[a] end
end

Either example, when used, will get the script's children, determine if the child is nil, and, if it isn't, return the child. Useless in actual scripting, of course, but it makes a decent example.

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