How can I get X number of children of a model using a for i,v in pairs loop? Sorry this is a request, but I can't get an answer anywhere else.
COMMUNITY QUESTION
How can I get X number of children?
1 answer
you can just use a regular for loop, like this:
local Children = Model:GetChildren() --Replace Model with whatever you want to get the children of
local NumChildren = 4 --Replace 4 with the number of children you want to get
local ObjectTable = {} --This is the table where the objects will be held
for i = 1,NumChildren do
table.insert(ObjectTable,Childen[i])
end
Note: The objects returned will not be random, and if the model is left unchanged, it will return the same objects all the time
This discussion is preserved as it was. New answers, comments, and votes are closed.
