This script works but, I am not trying to do it individual. I am trying to get all the parts in a model and print the total mass of all together, not individual. I would appreciate the help!
local Parts = script.Parent:GetChildren() local Table = {} for i,Part in pairs(Parts) do table.insert(Table,Part) end for i,Value in pairs(Table) do if Value:IsA('Part') then print(Value:GetMass()) end end
Have a variable, "Mass", and every time it loops, add to it then print it!
local Parts = script.Parent:GetChildren() local Table = {} for i,Part in pairs(Parts) do table.insert(Table,Part) end local mass = 0 for i,Value in pairs(Table) do if Value:IsA('Part') then mass = mass + Value:GetMass() end end print(mass)
This should get the mass of every part in a model...
local mass = 0 --The initial mass. Will have to be reset for every new time you use getMassTotal() function getMassTotal(v) --This function will repeat itself for every child of the selected object, and the children of that object, etc etc. if v:IsA("Part") then mass = mass + v:GetMass() end for _,b in pairs(v:GetChildren()) do getMassTotal(b) end end getMassTotal(model) --Replace model with whichever object you wish to search through.
^That should work rather well for searching for the masses of parts. You may want to add more types into the if v:IsA("Part") then
though, as there are more than one type of part.
Examples: WedgePart, UnionOperation, TrussPart, Seat, and SkateboardPlatform.
And probably some more i forgot. Sorry if you didn't really 'learn' anything from this, I'm a terrible teacher.
But hey, atleast you can make use of it.