This is bit hard to explain but... what method would i have to type to get a print-only version of the amount of objects a model has inside of it?
For instance, if i have a model in Workspace that contained 2 Parts, What would i type to get that value? Ty for the help. :)
The best solution to this would be recursive, so that we count objects inside of sub-models (as opposed to just direct children of the model we are talking about).
Here is our recursive statement:
function countParts(model) local number = 0; if model:IsA("BasePart") then number = 1; end for _,child in pairs(model:GetChildren()) do number = number + countParts(child); end return number; end
If there was a model of 5 parts in the workspace called "thing", then we could get that 5 using:
countParts(workspace.Thing)
Just place this script into the model. This will work. :)
local parts = 0 local stuff = script.Parent:GetChildren() for i = 1, #stuff do if stuff[i].ClassName == "Part" then parts = parts + 1 end end print("Parts: "..parts)