Roblox Wiki
Roblox Wiki
m (Robot: Changing Category:Lua Objects to Category:Classes)
m (Remove Category:Abstract classes)
(39 intermediate revisions by 7 users not shown)
Line 1: Line 1:
  +
{{Infobox class
A BasePart is a hierarchical class containing all members of any part. All parts implement this class, and though it cannot be instanced, it is very important.
 
  +
| explorer order = -1
<syntaxhighlight lang="lua">
 
  +
| tags = notbrowsable}}
function CheckIsPart(item)
 
return item:IsA('BasePart')
 
end
 
</syntaxhighlight>
 
   
  +
The '''BasePart''' [[class]] is a [[structural class]] that holds all the properties, methods and events common to part classes, such as {{Class link|Part}}, {{Class link|WedgePart}}, {{Class link|CornerWedgePart}}, {{Class link|TrussPart}}, {{Class link|SpawnLocation}}, {{Class link|Seat}}, {{Class link|VehicleSeat}}, {{Class link|SkateboardPlatform}}, and {{Class link|FlagStand}}. The most common is the simple part. While many of these classes extend the BasePart class directly, some extend the {{Class link|FormFactorPart}} class, which is itself a subclass of BasePart. The BasePart class cannot be [[Instantiation|instantiated]].
[[Category:Classes]]
 
  +
  +
== Properties ==
  +
  +
  +
  +
=== {{property|name=Anchored|type=bool}} ===
  +
  +
Determines whether or not physics acts upon the Part. If true, part stays 'Anchored' in space, not moving regardless of any collision/forces acting upon it. If false, physics works normally on the part.
  +
  +
=== {{property|name=BrickColor|type=BrickColor}} ===
  +
  +
The color of a part is set by the value of its BrickColor property. Brick colors are a set of pre-defined colors that the user may choose from to color parts, teams and other things in the ROBLOX engine.
  +
  +
=== {{property|name=CFrame|type=CoordinateFrame}} ===
  +
  +
Contains information regarding the Part's position and a matrix that defines the Part's rotation. Can read/write.
  +
  +
=== {{property|name=CanCollide|type=bool}} ===
  +
  +
Determines whether physical interactions with other Parts are respected. If true, will collide and react with physics to other Parts. If false, other parts will pass thru instead of colliding.
  +
  +
=== {{property|readonly|name=CenterOfMass|type=Vector3}} ===
  +
  +
=== {{property|name=CollisionGroupId|type=int}} ===
  +
  +
The id of the collision group this basepart is in. This can be used with [[Class:PhysicsService|PhysicsService]].
  +
  +
=== {{property|name=Color|type=Color3}} ===
  +
  +
The Color3 of the BasePart.
  +
  +
=== {{property|name=CustomPhysicalProperties|type=PhysicalProperties}} ===
  +
  +
A container that allows you to edit the physical properties of this basepart.
  +
  +
=== {{property|name=Elasticity|deprecated|hidden|type=float}} ===
  +
  +
A float value ranging from 0.0f to 1.0f. Sets how much the Part will rebound against another. a value of 1 is like a superball, and 0 is like a lead block.
  +
  +
=== {{property|name=Friction|type=float|hidden|deprecated}} ===
  +
  +
A float value ranging from 0.0f to 1.0f. Sets how much the Part will be able to slide. a value of 1 is no sliding, and 0 is no friction, so infinite sliding.
  +
  +
=== {{property|hidden|name=LocalTransparencyModifier|type=float}} ===
  +
  +
=== {{property|name=Locked|type=bool}} ===
  +
  +
Determines whether building tools (in-game and studio) can manipulate this Part. If true, no editing allowed. If false, editing is allowed.
  +
  +
=== {{property|name=Material|type=Material}} ===
  +
  +
Specifies the look and feel the Part should have. Note: this does not define the color the Part is, see BrickColor for that.
  +
  +
=== {{property|name=Orientation|type=Vector3}} ===
  +
  +
Rotation around X, Y, and Z axis. Rotations applied in YXZ order.
  +
  +
=== {{property|name=Position|type=Vector3}} ===
  +
  +
A part's position can be changed by modifying the value of this property.
  +
  +
=== {{property|hidden|readonly|name=ReceiveAge|type=float}} ===
  +
  +
=== {{property|name=Reflectance|type=float}} ===
  +
  +
Specifies how shiny the Part is. A value of 1 is completely reflective (chrome), while a value of 0 is no reflectance (concrete wall)
  +
  +
=== {{property|readonly|name=ResizeIncrement|type=int}} ===
  +
  +
Sets the value for the smallest change in size allowable by the Resize(NormalId, int) function.
  +
  +
=== {{property|readonly|name=ResizeableFaces|type=Faces}} ===
  +
  +
Sets the value for the faces allowed to be resized by the Resize(NormalId, int) function.
  +
  +
=== {{property|name=RotVelocity|type=Vector3}} ===
  +
  +
This property defines the rotational velocity of the part it belongs to.
  +
  +
=== {{property|name=Rotation|type=Vector3}} ===
  +
  +
The part's rotation.
  +
  +
=== {{property|name=Size|type=Vector3}} ===
  +
  +
This property defines the size of the part it belongs to.
  +
  +
=== {{property|deprecated|readonly|name=SpecificGravity|type=float}} ===
  +
  +
This property defines how many times more dense than ROBLOX's water the part it belongs to is. Its value depends on the part's material.
  +
  +
=== {{property|name=Transparency|type=float}} ===
  +
  +
Sets how visible an object is. A value of 1 makes the object invisible, while a value of 0 makes the object opaque.
  +
  +
=== {{property|name=Velocity|type=Vector3}} ===
  +
  +
How fast the Part is traveling in studs/second. This property is NOT recommended to be modified directly, unless there is good reason. Otherwise, try using a BodyForce to move a Part.
  +
  +
=== {{property|deprecated|name=brickColor|type=BrickColor}} ===
  +
  +
This property is deprecated and the [[#BrickColor|BrickColor]] property should be used instead.
  +
  +
=== Surface inputs ===
  +
  +
The surface input properties are used to specify an input for a specific surface.
  +
  +
==== {{property|name=BackSurfaceInput|type=InputType}} ====
  +
  +
==== {{property|name=BottomSurfaceInput|type=InputType}} ====
  +
  +
==== {{property|name=FrontSurfaceInput|type=InputType}} ====
  +
  +
==== {{property|name=LeftSurfaceInput|type=InputType}} ====
  +
  +
==== {{property|name=RightSurfaceInput|type=InputType}} ====
  +
  +
==== {{property|name=TopSurfaceInput|type=InputType}} ====
  +
  +
=== Surface types ===
  +
  +
The surface type properties can be used to change the appearance of a specific surface of a part. Surface types also change the behavior of parts with other parts they are sticking to.
  +
  +
==== {{property|name=BackSurface|type=SurfaceType}} ====
  +
  +
==== {{property|name=BottomSurface|type=SurfaceType}} ====
  +
  +
==== {{property|name=FrontSurface|type=SurfaceType}} ====
  +
  +
==== {{property|name=LeftSurface|type=SurfaceType}} ====
  +
  +
==== {{property|name=RightSurface|type=SurfaceType}} ====
  +
  +
==== {{property|name=TopSurface|type=SurfaceType}} ====
  +
  +
=== Surface parameters ===
  +
  +
The surface parameter properties are used to give parameters to certain surfaces of a part. These parameters are used, for example, by the motor part surface.
  +
  +
==== {{property|name=BackParamA|type=float}} ====
  +
  +
==== {{property|name=BackParamB|type=float}} ====
  +
  +
==== {{property|name=BottomParamA|type=float}} ====
  +
  +
==== {{property|name=BottomParamB|type=float}} ====
  +
  +
==== {{property|name=FrontParamA|type=float}} ====
  +
  +
==== {{property|name=FrontParamB|type=float}} ====
  +
  +
==== {{property|name=LeftParamA|type=float}} ====
  +
  +
==== {{property|name=LeftParamB|type=float}} ====
  +
  +
==== {{property|name=RightParamA|type=float}} ====
  +
  +
==== {{property|name=RightParamB|type=float}} ====
  +
  +
==== {{property|name=TopParamA|type=float}} ====
  +
  +
==== {{property|name=TopParamB|type=float}} ====
  +
  +
== Methods ==
  +
  +
  +
  +
=== {{method|void|name=BreakJoints}} ===
  +
  +
Destroys SurfaceJoints with all parts that are touching this Instance (including internal joints in the Instance, as in a Model).
  +
  +
=== {{method|bool|name=CanCollideWith|Instance part}} ===
  +
  +
=== {{method|Tuple|name=CanSetNetworkOwnership}} ===
  +
  +
=== {{method|Objects|name=GetConnectedParts|2 = bool recursive = false}} ===
  +
  +
=== {{method|Objects|name=GetJoints|RobloxPlaceSecurity}} ===
  +
  +
=== {{method|float|name=GetMass}} ===
  +
  +
Returns a number that is the mass of this Instance. Mass of a Part is immutable, and is changed only by the size of the Part.
  +
  +
=== {{method|Instance|name=GetNetworkOwner}} ===
  +
  +
=== {{method|bool|name=GetNetworkOwnershipAuto}} ===
  +
  +
=== {{method|deprecated|CoordinateFrame|name=GetRenderCFrame}} ===
  +
  +
=== {{method|Instance|name=GetRootPart}} ===
  +
  +
=== {{method|Objects|name=GetTouchingParts}} ===
  +
  +
Returns an array of all the parts touching this part.
  +
  +
=== {{method|bool|name=IsGrounded}} ===
  +
  +
Returns whether or not this BasePart is connected to an [[Anchor]]ed BasePart.
  +
  +
=== {{method|void|name=MakeJoints}} ===
  +
  +
Creates the appropriate SurfaceJoints with all parts that are touching this Instance (including internal joints in the Instance, as in a Model). This uses the SurfaceTypes defined on the surfaces of parts to create the appropriate welds.
  +
  +
=== {{method|bool|name=Resize|NormalId normalId|int deltaAmount}} ===
  +
  +
Resizes a Part in the direction of the face defined by 'NormalId', by the amount specified by 'deltaAmount'. If the operation will expand the part to intersect another Instance, the part will not resize at all. Return true if the call is successful, false otherwise.
  +
  +
=== {{method|void|name=SetNetworkOwner|2 = Instance playerInstance = nil}} ===
  +
  +
=== {{method|void|name=SetNetworkOwnershipAuto}} ===
  +
  +
=== {{method|deprecated|void|name=breakJoints}} ===
  +
  +
Deprecated. Use [[#BreakJoints|BreakJoints]] instead.
  +
  +
=== {{method|deprecated|float|name=getMass}} ===
  +
  +
Use [[#GetMass|GetMass]] instead.
  +
  +
=== {{method|deprecated|void|name=makeJoints}} ===
  +
  +
Use [[#MakeJoints|MakeJoints]] instead.
  +
  +
=== {{method|deprecated|bool|name=resize|NormalId normalId|int deltaAmount}} ===
  +
  +
=== {{method|Instance|name=SubtractAsync|Objects parts|3 = CollisionFidelity collisionfidelity = Default}} ===
  +
  +
=== {{method|Instance|name=UnionAsync|Objects parts|3 = CollisionFidelity collisionfidelity = Default}} ===
  +
  +
== Events ==
  +
  +
  +
  +
=== {{event|deprecated|name=LocalSimulationTouched|Instance part}} ===
  +
  +
Deprecated. Use [[#Touched|Touched]] instead.
  +
  +
=== {{event|deprecated|name=OutfitChanged}} ===
  +
  +
This event will be fired when one of the visual properties of the part it belongs to is changed.
  +
  +
=== {{event|deprecated|name=StoppedTouching|Instance otherPart}} ===
  +
  +
Deprecated. Use [[#TouchEnded|TouchEnded]] instead.
  +
  +
=== {{event|name=TouchEnded|Instance otherPart}} ===
  +
  +
Fired when the part stops touching another part
  +
  +
=== {{event|name=Touched|Instance otherPart}} ===
  +
  +
This event will be fired by the game engine when a part touches the part to which the event belongs.
  +
  +
=== {{event|deprecated|name=touched|Instance otherPart}} ===
  +
  +
This event is deprecated. The [[#Touched|Touched]] event should be used instead.
  +
  +
== External links ==
  +
  +
* {{DevHub class link}}
  +
* {{Roblox API Reference class link}}

Revision as of 05:19, 3 March 2019

The BasePart class is a structural class that holds all the properties, methods and events common to part classes, such as Part light iconPart dark iconPart, WedgePart light iconWedgePart dark iconWedgePart, CornerWedgePart light iconCornerWedgePart dark iconCornerWedgePart, TrussPart light iconTrussPart dark iconTrussPart, SpawnLocation light iconSpawnLocation dark iconSpawnLocation, Seat light iconSeat dark iconSeat, VehicleSeat light iconVehicleSeat dark iconVehicleSeat, SkateboardPlatform light iconSkateboardPlatform dark iconSkateboardPlatform, and FlagStand light iconFlagStand dark iconFlagStand. The most common is the simple part. While many of these classes extend the BasePart class directly, some extend the FormFactorPart class, which is itself a subclass of BasePart. The BasePart class cannot be instantiated.

Properties

Anchored: bool

Determines whether or not physics acts upon the Part. If true, part stays 'Anchored' in space, not moving regardless of any collision/forces acting upon it. If false, physics works normally on the part.

BrickColor: BrickColor

The color of a part is set by the value of its BrickColor property. Brick colors are a set of pre-defined colors that the user may choose from to color parts, teams and other things in the ROBLOX engine.

CFrame: CoordinateFrame

Contains information regarding the Part's position and a matrix that defines the Part's rotation. Can read/write.

CanCollide: bool

Determines whether physical interactions with other Parts are respected. If true, will collide and react with physics to other Parts. If false, other parts will pass thru instead of colliding.

CenterOfMass: Vector3

CollisionGroupId: int

The id of the collision group this basepart is in. This can be used with PhysicsService.

Color: Color3

The Color3 of the BasePart.

CustomPhysicalProperties: PhysicalProperties

A container that allows you to edit the physical properties of this basepart.

Elasticity: float

A float value ranging from 0.0f to 1.0f. Sets how much the Part will rebound against another. a value of 1 is like a superball, and 0 is like a lead block.

Friction: float

A float value ranging from 0.0f to 1.0f. Sets how much the Part will be able to slide. a value of 1 is no sliding, and 0 is no friction, so infinite sliding.

LocalTransparencyModifier: float

Locked: bool

Determines whether building tools (in-game and studio) can manipulate this Part. If true, no editing allowed. If false, editing is allowed.

Material: Material

Specifies the look and feel the Part should have. Note: this does not define the color the Part is, see BrickColor for that.

Orientation: Vector3

Rotation around X, Y, and Z axis. Rotations applied in YXZ order.

Position: Vector3

A part's position can be changed by modifying the value of this property.

ReceiveAge: float

Reflectance: float

Specifies how shiny the Part is. A value of 1 is completely reflective (chrome), while a value of 0 is no reflectance (concrete wall)

ResizeIncrement: int

Sets the value for the smallest change in size allowable by the Resize(NormalId, int) function.

ResizeableFaces: Faces

Sets the value for the faces allowed to be resized by the Resize(NormalId, int) function.

RotVelocity: Vector3

This property defines the rotational velocity of the part it belongs to.

Rotation: Vector3

The part's rotation.

Size: Vector3

This property defines the size of the part it belongs to.

SpecificGravity: float

This property defines how many times more dense than ROBLOX's water the part it belongs to is. Its value depends on the part's material.

Transparency: float

Sets how visible an object is. A value of 1 makes the object invisible, while a value of 0 makes the object opaque.

Velocity: Vector3

How fast the Part is traveling in studs/second. This property is NOT recommended to be modified directly, unless there is good reason. Otherwise, try using a BodyForce to move a Part.

brickColor: BrickColor

This property is deprecated and the BrickColor property should be used instead.

Surface inputs

The surface input properties are used to specify an input for a specific surface.

BackSurfaceInput: InputType

BottomSurfaceInput: InputType

FrontSurfaceInput: InputType

LeftSurfaceInput: InputType

RightSurfaceInput: InputType

TopSurfaceInput: InputType

Surface types

The surface type properties can be used to change the appearance of a specific surface of a part. Surface types also change the behavior of parts with other parts they are sticking to.

BackSurface: SurfaceType

BottomSurface: SurfaceType

FrontSurface: SurfaceType

LeftSurface: SurfaceType

RightSurface: SurfaceType

TopSurface: SurfaceType

Surface parameters

The surface parameter properties are used to give parameters to certain surfaces of a part. These parameters are used, for example, by the motor part surface.

BackParamA: float

BackParamB: float

BottomParamA: float

BottomParamB: float

FrontParamA: float

FrontParamB: float

LeftParamA: float

LeftParamB: float

RightParamA: float

RightParamB: float

TopParamA: float

TopParamB: float

Methods

BreakJoints(): void

Destroys SurfaceJoints with all parts that are touching this Instance (including internal joints in the Instance, as in a Model).

CanCollideWith(part: Instance): bool

CanSetNetworkOwnership(): Tuple

GetConnectedParts(recursive: bool = false): Objects

GetJoints(): Objects

GetMass(): float

Returns a number that is the mass of this Instance. Mass of a Part is immutable, and is changed only by the size of the Part.

GetNetworkOwner(): Instance

GetNetworkOwnershipAuto(): bool

GetRenderCFrame(): CoordinateFrame

GetRootPart(): Instance

GetTouchingParts(): Objects

Returns an array of all the parts touching this part.

IsGrounded(): bool

Returns whether or not this BasePart is connected to an Anchored BasePart.

MakeJoints(): void

Creates the appropriate SurfaceJoints with all parts that are touching this Instance (including internal joints in the Instance, as in a Model). This uses the SurfaceTypes defined on the surfaces of parts to create the appropriate welds.

Resize(normalId: NormalId, deltaAmount: int): bool

Resizes a Part in the direction of the face defined by 'NormalId', by the amount specified by 'deltaAmount'. If the operation will expand the part to intersect another Instance, the part will not resize at all. Return true if the call is successful, false otherwise.

SetNetworkOwner(playerInstance: Instance = nil): void

SetNetworkOwnershipAuto(): void

breakJoints(): void

Deprecated. Use BreakJoints instead.

getMass(): float

Use GetMass instead.

makeJoints(): void

Use MakeJoints instead.

resize(normalId: NormalId, deltaAmount: int): bool

SubtractAsync(parts: Objects, collisionfidelity: CollisionFidelity = Default): Instance

UnionAsync(parts: Objects, collisionfidelity: CollisionFidelity = Default): Instance

Events

LocalSimulationTouched(part: Instance)

Deprecated. Use Touched instead.

OutfitChanged()

This event will be fired when one of the visual properties of the part it belongs to is changed.

StoppedTouching(otherPart: Instance)

Deprecated. Use TouchEnded instead.

TouchEnded(otherPart: Instance)

Fired when the part stops touching another part

Touched(otherPart: Instance)

This event will be fired by the game engine when a part touches the part to which the event belongs.

touched(otherPart: Instance)

This event is deprecated. The Touched event should be used instead.

External links