PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetMass

The GetMass function returns the BasePart|part's mass.

This can vary depending on the part’s BasePart/Material|material and the size. The Enum/Material| material enum page contains a table of all materials and their densities. Parts made of materials with greater densities have more mass than equally sized parts made of materials with lesser densities.

Note that a part’s density differs from the densities listed on the material page if the part’s BasePart/CustomPhysicalProperties property is set.

You can also determine location of the part’s center of mass via the BasePart/CenterOfMass property.

Returns

Return Type Summary

The part’s mass


Code Samples


Finding a Part's Mass

This example creates a new part, myPart, in the game’s Workspace, with dimensions 4x6x4 studs. The part is also anchored.

Then, myMass is set to equal the mass of the new part. The mass of the part is printed at the end of the print statement:

My part’s mass is …

local myPart = Instance.new("Part")
myPart.Parent = game.Workspace
myPart.Size = Vector3.new(4, 6, 4)
myPart.Anchored = true
 
local myMass = myPart:GetMass()
 
print("My part's mass is " .. myMass)