for example:
How would i get the number of models inside GSOseat?
5 Likes
Try using a print statement that shows it. Or just manually count them.
1 Like
The reason i need this is because there could me no models/ a lot of models at any time. (it has the placed parts inside it)
2 Likes
Idk then, Use one of those multi object print statments and put a wait(30) do loop on it. That will print it every 30 seconds and update the number of models.
1 Like
You can get the number of descendants or children of an instance using this
#GSOseat:GetChildren() --> returns the number of children inside a model
3 Likes
local childs = workspace.GSOseat:GetChildren()
for i = 1, #children do
local child = children[i]
print(child.Name .. " is child number " .. i)
end
But how would i filter out all the objects that are not models using this?
function getmodels()
local number = 0
for i, v in pairs(GSOseat:GetChildren()) do
if v:IsA("Model") then
number = number + 1
end
end
return number -- > count of all objects parented to "GSOseat" which are models
end
5 Likes
#GSOseat:GetChildren()
is a much simpler way of doing that. This is solved already, but just saying.
1 Like
That would return everything, including non-models. OP needs only the models.