Part
A solid object which is used as a basic building piece.
A Part is a physical object with a position, a size, a look, and a collision shape. Most of any place consists of parts that build the look and style of the game.
Creating one
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
Position and size
| Property | Type | What it does |
|---|---|---|
| CFrame | CFrame | Position and rotation together. |
| Position | Vector3 | The center, in studs. |
| Orientation | Vector3 | Rotation in degrees. Rotation is an alias. |
| Size | Vector3 | Extents in studs. Each axis is clamped from 0.001 to 2048. |
Writing CFrame or Position on a part that belongs to a character moves the whole character so the limb lands there, not just the limb.
A Sphere uses its X value for all three axes. A Cylinder uses X for both X and Z and keeps Y, so setting Size to (2, 5, 9) on one reads back as (2, 5, 2).
Appearance
| Property | Type | What it does |
|---|---|---|
| Color | Color3 | The surface color. |
| BrickColor | BrickColor | Reading returns the palette entry closest to Color. Writing also accepts a Color3. |
| Transparency | number | 0 is solid, 1 is invisible. Not clamped. |
| Reflectance | number | How mirror-like the surface is. Not clamped. |
| Metallic | number | Clamped from 0 to 1. |
| Roughness | number | Clamped from 0 to 1. |
| Material | Enum.Material | The surface material, by enum item, name, or number. |
| Shape | Enum.PartType | The primitive shape. Also takes the strings Block, Ball, Sphere, Cylinder, Wedge, and CornerWedge. |
BrickColor is only a view of Color: the part stores channels, not a palette number, so two palette colors with the same channels are indistinguishable when read back.
Shape prefers the strings. The enum values for Ball and Cylinder are numbered differently from the stored shapes, so Enum.PartType.Cylinder gives you a sphere and Enum.PartType.Ball gives you a cylinder. Enum holds the full list.
Physics
| Property | Type | What it does |
|---|---|---|
| Anchored | boolean | A part that does not fall or move on its own. |
| CanCollide | boolean | Whether other parts collide with it. |
| CastShadow | boolean | Whether it casts a shadow. |
| Mass | number | Read-only. The size cubed times the density, or 0 when Massless. |
| Massless | boolean | Excludes the part from the assembly's mass. |
| Velocity | Vector3 | World velocity in studs per second. |
| AssemblyLinearVelocity | Vector3 | The part's own linear velocity. It reads and writes the same value as Velocity. |
| AssemblyAngularVelocity | Vector3 | The part's own angular velocity, in the solver's units. Nothing propagates it to other parts. |
| CustomPhysicalProperties | table or nil | Density, Friction, Elasticity, FrictionWeight, and ElasticityWeight, as a table. nil clears it. |
Writing a velocity value wakes a sleeping part, but only when the value actually changes.
Events
| Event | Callback arguments | When it fires |
|---|---|---|
| Touched | part | Fires when contact with another part began. |
It does not fire again while the two parts stay in contact, only after they separate and touch again. Handlers run in Scripts and LocalScripts.
Surfaces
A part draws six faces, and each face has its own property. All six take an Enum.SurfaceType, a name, or a number.
| Property | Face |
|---|---|
| TopSurface | Top |
| BottomSurface | Bottom |
| FrontSurface | Front |
| BackSurface | Back |
| RightSurface | Right |
| LeftSurface | Left |
The faces are the same ones Enum.NormalId lists. Only Studs and Inlet survive a write; every other value keeps its number but renders and reads back as Smooth. Enum lists every item of both lists.
Members
Part has the members every Instance has, and no methods of its own. See Instance.
Example
local platform = Instance.new("Part")
platform.Name = "Platform"
platform.Size = Vector3.new(20, 1, 20)
platform.Position = Vector3.new(0, 0, 0)
platform.Anchored = true
platform.Color = Color3.fromRGB(90, 140, 200)
platform.Parent = workspace
Any unanchored part starts falling as soon as it is parented into Workspace.
See also
- MeshPart: a part with a mesh shape.
- CFrame: positions and rotations.
- Enum: materials, shapes, and surface types.
- Instance: the shared members.
- API Reference