BasePart

Inherits Instance

BasePart provides the foundation for all 3D objects that can exist in the workspace. It handles physics properties like position, rotation, velocity, and collision. All parts inherit from this class and gain access to physical simulation capabilities.

Examples

-- BasePart is abstract, use Part or other subclasses
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = false

Properties

Position

Vector3

The 3D position of the part in world space

Rotation

Vector3

The rotation angles in degrees (X, Y, Z)

Size

Vector3

The dimensions of the part

Velocity

Vector3

The current velocity of the part

RotationVelocity

Vector3

The angular velocity of the part

Anchored

bool

When true, the part is not affected by physics

CanCollide

bool

When true, the part can collide with other parts

CanQuery

bool

When true, the part can be detected by raycasts

CanTouch

bool

When true, the part can trigger touch events

Mass

number Read-only

The mass of the part calculated from size and material

Color

Color3

The color of the part

CastShadow

bool

When true, the part casts shadows

Transparency

number

The transparency of the part from 0 (opaque) to 1 (invisible)

Parent

Instance | nil Inherited from Instance

The parent of this instance in the hierarchy

Archivable

bool Inherited from Instance

When true, the instance can be saved and cloned

Name

string Inherited from Instance

The name of this instance

ClassName

string Read-only Inherited from Object

The name of this object's class

Methods

GetMass()

number

Returns the calculated mass of the part

local mass = part:GetMass()
print("Mass:", mass)

AddTag(tag: string)

void Inherited from Instance

Adds a tag to this instance

Parameters:

  • tag string

HasTag(tag: string)

bool Inherited from Instance

Checks if this instance has a specific tag

Parameters:

  • tag string

RemoveTag(tag: string)

void Inherited from Instance

Removes a tag from this instance

Parameters:

  • tag string

GetAttribute(attribute: string)

Attribute | nil Inherited from Instance

Gets the value of an attribute

Parameters:

  • attribute string

GetAttributes()

table Inherited from Instance

Returns a table of all attributes

SetAttribute(attribute: string, value: Attribute)

void Inherited from Instance

Sets the value of an attribute

Parameters:

  • attribute string
  • value Attribute
part:SetAttribute("Health", 100)
local health = part:GetAttribute("Health")

FindFirstAncestor(name: string)

Instance | nil Inherited from Instance

Finds the first ancestor with the specified name

Parameters:

  • name string

FindFirstAncestorOfClass(className: string)

Instance | nil Inherited from Instance

Finds the first ancestor of the specified class

Parameters:

  • className string

FindFirstAncestorWhichIsA(className: string)

Instance | nil Inherited from Instance

Finds the first ancestor that is an instance of the class

Parameters:

  • className string

FindFirstChild(name: string)

Instance | nil Inherited from Instance

Finds the first direct child with the specified name

Parameters:

  • name string

FindFirstChildOfClass(name: string)

Instance | nil Inherited from Instance

Finds the first direct child of the specified class

Parameters:

  • name string

FindFirstChildWhichIsA(name: string)

Instance | nil Inherited from Instance

Finds the first child that is an instance of the class

Parameters:

  • name string

FindFirstDescendant(name: string)

Instance | nil Inherited from Instance

Finds the first descendant with the specified name

Parameters:

  • name string

GetChildren()

table Inherited from Instance

Returns an array of all direct children

for _, child in ipairs(workspace:GetChildren()) do
print(child.Name)
end

GetDescendants()

table Inherited from Instance

Returns an array of all descendants

IsAncestorOf(descendant: Instance)

bool Inherited from Instance

Checks if this instance is an ancestor of the target

Parameters:

  • descendant Instance

IsDescendantOf(ancestor: Instance)

bool Inherited from Instance

Checks if this instance is a descendant of the target

Parameters:

  • ancestor Instance

ClearAllChildren()

void Inherited from Instance

Removes and destroys all children

Destroy()

void Inherited from Instance

Permanently destroys this instance and all descendants

SetParent(newParent: Instance)

void Inherited from Instance

Sets the parent of this instance

Parameters:

  • newParent Instance - | nil

AddChild(child: Instance)

void Inherited from Instance

Adds a child to this instance

Parameters:

  • child Instance

RemoveChild(child: Instance)

void Inherited from Instance

Removes a child from this instance

Parameters:

  • child Instance

IsA(className: string)

bool Inherited from Object

Checks if this object is an instance of the specified class

Parameters:

  • className string

FirePropertyChanged(propertyName: string)

void Inherited from Object

Triggers the Changed event for a specific property

Parameters:

  • propertyName string

Events

Touched

Event(otherPart: BasePart)

Fires when another part touches this part

part.Touched:Connect(function(otherPart)
print("Touched by:", otherPart.Name)
end)

TouchEnded

Event(otherPart: BasePart)

Fires when another part stops touching this part

AncestryChanged

Event(child: Instance, parent: Instance) Inherited from Instance

Fires when the instance's ancestry changes

AttributeChanged

Event(attributeName: string) Inherited from Instance

Fires when an attribute is changed

ChildAdded

Event(child: Instance) Inherited from Instance

Fires when a child is added to this instance

ChildRemoved

Event(child: Instance) Inherited from Instance

Fires when a child is removed from this instance

DescendantAdded

Event(descendant: Instance) Inherited from Instance

Fires when a descendant is added anywhere in the tree

DescendantRemoving

Event(descendant: Instance) Inherited from Instance

Fires when a descendant is about to be removed

Destroying

Event() Inherited from Instance

Fires when this instance is being destroyed

Changed

Event(propertyName: string) Inherited from Object

Fires when a property of this object changes

part.Changed:Connect(function(property)
print("Property changed:", property)
end)