Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to get data in a table with :GetChildren?

Asked by 8 years ago

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
GetChildren returns a table of all objects inside the model/folder. So a table is basically already one. HungryJaffer 1246 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

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

0
thanks chabad360 34 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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.

Answer this question