BasePartクラス

クラスInstance.newでは作れない日本語解説あり

ひとことで言うと

Part・MeshPartなど、ゲームの世界に置かれる「形のある部品」すべての元になるクラスです。位置・大きさ・色・固定(Anchored)・当たり判定などを決めます。

公式の説明(英語):The abstract base class for in-world objects that physically interact.

BasePart自体は直接作れません(Instance.newで作るのは Part などの子クラスです)。ここにあるプロパティやイベントは、Part・MeshPart・SpawnLocationなどで共通して使えます。

使用例

ふれたプレイヤーを倒すブロック(キルブロック)
Script置く場所:パーツの中
local part = script.Parent :: BasePart

part.Touched:Connect(function(hit)
	local character = hit.Parent
	if not character then
		return
	end
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)
ふれると消える床
Script置く場所:パーツの中
local part = script.Parent :: BasePart
local debounce = false

part.Touched:Connect(function(hit)
	if debounce then
		return
	end
	local character = hit.Parent
	if not character or not character:FindFirstChildWhichIsA("Humanoid") then
		return
	end
	debounce = true
	task.wait(0.5)
	part.Transparency = 1
	part.CanCollide = false
	task.wait(3)
	part.Transparency = 0
	part.CanCollide = true
	debounce = false
end)

スクリプトは、Luauの型チェック(luau-lsp)で確認しています。

クラスの関係

受け継いでいるクラス:Object → Instance → PVInstance → BasePart

このクラスを受け継ぐクラス:Terrain、CornerWedgePart、FormFactorPart、TriangleMeshPart、TrussPart、VehicleSeat

プロパティ(40)

名前と書き方説明
Anchored
BasePart.Anchored: boolean
trueにすると、パーツが空中に固定され、物理の力(重力など)で動かなくなります。Determines whether a part is immovable by physics.
AssemblyAngularVelocity
BasePart.AssemblyAngularVelocity: Vector3
The angular velocity of the part's assembly.
AssemblyCenterOfMass
BasePart.AssemblyCenterOfMass: Vector3
The center of mass of the part's assembly in world space.
AssemblyLinearVelocity
BasePart.AssemblyLinearVelocity: Vector3
パーツ(とつながったパーツ全体)の速度。値を入れると、その方向に飛ばせます。The linear velocity of the part's assembly.
AssemblyMass
BasePart.AssemblyMass: float
The total mass of the part's assembly.
AssemblyRootPart
BasePart.AssemblyRootPart: BasePart
A reference to the root part of the assembly.
AudioCanCollide
BasePart.AudioCanCollide: boolean
Determines whether the part will physically interact with audio simulation, similar to Class.BasePart.CastShadow|CastShadow for lighting.
BackSurface
BasePart.BackSurface: SurfaceType
Determines the type of surface for the back face of a part.
BottomSurface
BasePart.BottomSurface: SurfaceType
Determines the type of surface for the bottom face of a part.
BrickColor
BasePart.BrickColor: BrickColor
パーツの色を、名前の付いた色(BrickColor)で指定します。Determines the color of a part.
CanCollide
BasePart.CanCollide: boolean
falseにすると、プレイヤーや他のパーツがすり抜けられるようになります。Determines whether a part may collide with other parts.
CanQuery
BasePart.CanQuery: boolean
Determines whether the part is considered during spatial query operations.
CanTouch
BasePart.CanTouch: boolean
falseにすると、Touchedイベントが発生しなくなります。Determines if Class.BasePart.Touched|Touched and Class.BasePart.TouchEnded|TouchEnded events fire on the part.
CastShadow
BasePart.CastShadow: boolean
Determines whether or not a part casts a shadow.
CenterOfMass
BasePart.CenterOfMass: Vector3
Describes the local position of a part's center of mass, relative to its Class.BasePart.CFrame|CFrame.
CFrame
BasePart.CFrame: CFrame
パーツの位置と向きをまとめて表す値(CFrame)。Determines the position and orientation of the BasePart in the world.
CollisionGroup
BasePart.CollisionGroup: string
Describes the name of a part's collision group.
Color
BasePart.Color: Color3
パーツの色(Color3)。Determines the color of a part.
CurrentPhysicalProperties
BasePart.CurrentPhysicalProperties: PhysicalProperties
Indicates the current physical properties of the part.
CustomPhysicalProperties
BasePart.CustomPhysicalProperties: PhysicalProperties
Determines several physical properties of a part.
EnableFluidForces
BasePart.EnableFluidForces: boolean
Used to enable or disable aerodynamic forces on parts and assemblies.
ExtentsCFrame
BasePart.ExtentsCFrame: CFrame
The CFrame of the physical extents of the BasePart.
ExtentsSize
BasePart.ExtentsSize: Vector3
The actual physical size of the BasePart as regarded by the physics engine.
FrontSurface
BasePart.FrontSurface: SurfaceType
Determines the type of surface for the front face of a part.
LeftSurface
BasePart.LeftSurface: SurfaceType
Determines the type of surface for the left face of a part.
Locked
BasePart.Locked: boolean
Determines whether a part is selectable in Studio.
Mass
BasePart.Mass: float
パーツの重さ。読み取り専用です。Describes the mass of the part, the product of its density and volume.
Massless
BasePart.Massless: boolean
Determines whether the part contributes to the total mass or inertia of its rigid body.
Material
BasePart.Material: Material
パーツの素材(木・金属・ネオンなど)。見た目と音が変わります。Determines the texture and default physical properties of a part.
MaterialVariant
BasePart.MaterialVariant: string
The name of MaterialVariant.
PivotOffset
BasePart.PivotOffset: CFrame
Specifies the offset of the part's pivot from its CFrame.
Reflectance
BasePart.Reflectance: float
反射の強さ。0〜1で指定します。Determines how much a part reflects the skybox.
ResizeableFaces
BasePart.ResizeableFaces: Faces
Describes the faces on which a part may be resized.
ResizeIncrement
BasePart.ResizeIncrement: int
Describes the smallest change in size allowable by the Class.BasePart:Resize()|Resize() method.
RightSurface
BasePart.RightSurface: SurfaceType
Determines the type of surface for the right face of a part.
RootPriority
BasePart.RootPriority: int
The main rule in determining the root part of an assembly.
Rotation
BasePart.Rotation: Vector3
The rotation of the part in degrees for the three axes.
Size
BasePart.Size: Vector3
パーツの大きさ(Vector3)。Determines the dimensions of a part (length, height, width).
TopSurface
BasePart.TopSurface: SurfaceType
Determines the type of surface for the top face of a part.
Transparency
BasePart.Transparency: float
透明度。0で不透明、1で完全に見えなくなります。Determines how much a part can be seen through (the inverse of part opacity).

メソッド(24)

名前と書き方説明
AngularAccelerationToTorque
BasePart:AngularAccelerationToTorque(angAcceleration: Vector3, angVelocity: Vector3): Vector3
Returns the torque needed to achieve a given angular acceleration on this part's assembly, optionally accounting for gyroscopic effects.
ApplyAngularImpulse
BasePart:ApplyAngularImpulse(impulse: Vector3): ()
Apply an angular impulse to the assembly.
ApplyImpulse
BasePart:ApplyImpulse(impulse: Vector3): ()
パーツに瞬間的な力を加えます。Apply an impulse to the assembly at the assembly's Class.BasePart.AssemblyCenterOfMass|center of mass.
ApplyImpulseAtPosition
BasePart:ApplyImpulseAtPosition(impulse: Vector3, position: Vector3): ()
Apply an impulse to the assembly at specified position.
BindToCollisionSummaries
BasePart:BindToCollisionSummaries(callback: Function): RBXScriptConnection
Subscribes to detailed per-frame contact data for the collisions this part is involved in.
CanCollideWith
BasePart:CanCollideWith(part: BasePart): boolean
Returns whether the parts can collide with each other.
CanSetNetworkOwnership
BasePart:CanSetNetworkOwnership(): Tuple
Checks whether you can set a part's network ownership.
GetClosestPointOnSurface
BasePart:GetClosestPointOnSurface(position: Vector3): Vector3
Returns the closest point on the part's surface to the given point.
GetConnectedParts
BasePart:GetConnectedParts(recursive: boolean): List<BasePart>
Returns a table of parts connected to the object by any kind of rigid joint.
GetJoints
BasePart:GetJoints(): Instances
Returns all Joints or Constraints connected to this part that are active in the simulation.
GetMass
BasePart:GetMass(): float
Returns the value of the Class.BasePart.Mass|Mass property.
GetNetworkOwner
BasePart:GetNetworkOwner(): Instance
Returns the current player who is the network owner of this part, or nil in case of the server.
GetNetworkOwnershipAuto
BasePart:GetNetworkOwnershipAuto(): boolean
Returns true if the game engine automatically decides the network owner for this part.
GetNoCollisionConstraints
BasePart:GetNoCollisionConstraints(): Instances
Returns the enabled NoCollisionConstraint objects currently registered for this part in its physics world.
GetTouchingParts
BasePart:GetTouchingParts(): Instances
今ふれているパーツをすべて返します。Returns a table of all BasePart.CanCollide true parts that intersect with this part.
GetVelocityAtPosition
BasePart:GetVelocityAtPosition(position: Vector3): Vector3
Returns the linear velocity of the part's assembly at the given position relative to this part.
IntersectAsync
BasePart:IntersectAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance
Creates a new IntersectOperation from the overlapping geometry of the part and the other parts in the given array.
IsGrounded
BasePart:IsGrounded(): boolean
Returns true if the object is connected to a part that will hold it in place (eg an Class.BasePart.Anchored|Anchored part), otherwise returns false.
Resize
BasePart:Resize(normalId: NormalId, deltaAmount: int): boolean
Changes the size of an object just like using the Studio resize tool.
SetNetworkOwner
BasePart:SetNetworkOwner(playerInstance: Player): ()
Sets the given player as network owner for this and all connected parts.
SetNetworkOwnershipAuto
BasePart:SetNetworkOwnershipAuto(): ()
Lets the game engine dynamically decide who will handle the part's physics (one of the clients or the server).
SubtractAsync
BasePart:SubtractAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance
Creates a new UnionOperation from the part, minus the geometry occupied by the parts in the given array.
TorqueToAngularAcceleration
BasePart:TorqueToAngularAcceleration(torque: Vector3, angVelocity: Vector3): Vector3
Returns the angular acceleration that would result from applying a given torque to this part's assembly, optionally accounting for gyroscopic effects.
UnionAsync
BasePart:UnionAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance
Creates a new UnionOperation from the part, plus the geometry occupied by the parts in the given array.

イベント(2)

名前と書き方説明
Touched
BasePart.Touched(otherPart: BasePart)
他のパーツがふれたときに発生するイベントです。ふれたパーツが引数で渡されます。Fires when a part touches another part as a result of physical movement.
TouchEnded
BasePart.TouchEnded(otherPart: BasePart)
ふれていたパーツが離れたときに発生するイベントです。Fires when a part stops touching another part as a result of physical movement.

受け継いでいるメンバー

PVInstance から受け継いでいるもの(4)

Origin・Pivot Offset・GetPivot・PivotTo

Instance から受け継いでいるもの(46)

Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged

Object から受け継いでいるもの(4)

ClassName・GetPropertyChangedSignal・IsA・Changed

BasePartを使う記事

英語の説明とメンバーの一覧は、Roblox Creator Documentation(BasePart)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む