:GetMass() for collections of parts

I’ve run into just as many cases where I needed to know the mass of a collection of parts as I did just of a single part. In each of those cases, I have needed to create my own getRecursiveMass(obj) function (and I’m pretty sure I’ve seen that in some ROBLOX gear as well) – it’d be nice if there was a clean way to get the recursive mass of a collection of parts as its usage is just as common as non-recursive mass in my experiences. Adding a boolean as a parameter to :GetMass() that when true returns the recursive mass would do the trick:

print(part:GetMass(true))

collective mass of all parts currently attached to part

I wouldn’t think model:GetMass() would be appropriate as just because two objects are in a model doesn’t necessarily mean they’re attached to each other, and there’s no need to get the mass of non-attached parts / anchored parts because you wouldn’t be working with mass in that case.

4 Likes