เรียนรู้
Engine Class
BasePart
ไม่สามารถสร้าง
ไม่สามารถเรียกดู

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
คุณสมบัติ
BackParamA:number
เลิกใช้แล้ว
BackParamB:number
เลิกใช้แล้ว
BackSurfaceInput:Enum.InputType
เลิกใช้แล้ว
BottomParamA:number
เลิกใช้แล้ว
BottomParamB:number
เลิกใช้แล้ว
BottomSurfaceInput:Enum.InputType
เลิกใช้แล้ว
brickColor:BrickColor
เลิกใช้แล้ว
CollisionGroupId:number
เลิกใช้แล้ว
Elasticity:number
เลิกใช้แล้ว
Friction:number
เลิกใช้แล้ว
FrontParamA:number
เลิกใช้แล้ว
FrontParamB:number
เลิกใช้แล้ว
FrontSurfaceInput:Enum.InputType
เลิกใช้แล้ว
LeftParamA:number
เลิกใช้แล้ว
LeftParamB:number
เลิกใช้แล้ว
LeftSurfaceInput:Enum.InputType
เลิกใช้แล้ว
RightParamA:number
เลิกใช้แล้ว
RightParamB:number
เลิกใช้แล้ว
RightSurfaceInput:Enum.InputType
เลิกใช้แล้ว
RotVelocity:Vector3
เลิกใช้แล้ว
SpecificGravity:number
เลิกใช้แล้ว
TopParamA:number
เลิกใช้แล้ว
TopParamB:number
เลิกใช้แล้ว
TopSurfaceInput:Enum.InputType
เลิกใช้แล้ว
Velocity:Vector3
เลิกใช้แล้ว
วิธีการ
AngularAccelerationToTorque(angAcceleration: Vector3,angVelocity: Vector3):Vector3
ApplyImpulse(impulse: Vector3):()
ApplyImpulseAtPosition(impulse: Vector3,position: Vector3):()
BreakJoints():()
เลิกใช้แล้ว
breakJoints():()
เลิกใช้แล้ว
GetJoints():Instances
getMass():number
เลิกใช้แล้ว
GetRenderCFrame():CFrame
เลิกใช้แล้ว
GetRootPart():Instance
เลิกใช้แล้ว
GetTouchingParts():Instances
IntersectAsync(parts: Instances,collisionfidelity: Enum.CollisionFidelity,renderFidelity: Enum.RenderFidelity):Instance
MakeJoints():()
เลิกใช้แล้ว
makeJoints():()
เลิกใช้แล้ว
Resize(normalId: Enum.NormalId,deltaAmount: number):boolean
resize(normalId: Enum.NormalId,deltaAmount: number):boolean
เลิกใช้แล้ว
SetNetworkOwner(playerInstance: Player):()
SubtractAsync(parts: Instances,collisionfidelity: Enum.CollisionFidelity,renderFidelity: Enum.RenderFidelity):Instance
UnionAsync(parts: Instances,collisionfidelity: Enum.CollisionFidelity,renderFidelity: Enum.RenderFidelity):Instance
เหตุการณ์
LocalSimulationTouched(part: BasePart):RBXScriptSignal
เลิกใช้แล้ว
OutfitChanged():RBXScriptSignal
เลิกใช้แล้ว
StoppedTouching(otherPart: BasePart):RBXScriptSignal
เลิกใช้แล้ว
สมาชิกที่ได้รับทอด
ได้รับทอดโดย
CornerWedgePart, FormFactorPart, Terrain, TriangleMeshPart, TrussPart,
ตัวอย่างโค้ด
การทำให้ CFrame ของ Part ราบรื่น
local TweenService = game:GetService("TweenService")
-- สร้างส่วนและเป้าหมาย
local part = Instance.new("Part", workspace)
part.Size = Vector3.one
part.Anchored = true
part.BrickColor = BrickColor.new("Electric blue")
part.CFrame = CFrame.new(0, 4, 0)
local target = Instance.new("Part", workspace)
target.Name = "Target"
target.Size = Vector3.one * 0.5
target.Anchored = true
target.BrickColor = BrickColor.new("Really red")
target.CFrame = CFrame.new(0, 8, 0)
-- ตั้งค่าตัวแปรเพื่อเก็บความเร็ว
local velocity = CFrame.new()
-- ปรับความเร็วในการทำให้ราบรื่น
local smoothTime = 0.5
game:GetService("RunService").Stepped:Connect(function(t, dt)
part.CFrame, velocity = TweenService:SmoothDamp(part.CFrame, target.CFrame, velocity, smoothTime, math.huge, dt)
end)

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Anchored
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Anchored:boolean
ตัวอย่างโค้ด
สลับการตรึงส่วน
local part = script.Parent
-- สร้าง ClickDetector เพื่อให้เราสามารถบอกได้เมื่อส่วนถูกคลิก
local cd = Instance.new("ClickDetector", part)
-- ฟังก์ชันนี้ปรับปรุงว่าอย่างไรส่วนดูตามสถานะ Anchored ของมัน
local function updateVisuals()
if part.Anchored then
-- เมื่อส่วนถูกตรึง...
part.BrickColor = BrickColor.new("Bright red")
part.Material = Enum.Material.DiamondPlate
else
-- เมื่อส่วนไม่ถูกตรึง...
part.BrickColor = BrickColor.new("Bright yellow")
part.Material = Enum.Material.Wood
end
end
local function onToggle()
-- สลับคุณสมบัติการตรึง
part.Anchored = not part.Anchored
-- อัปเดตสถานะรูปลักษณ์ของอิฐ
updateVisuals()
end
-- อัปเดต จากนั้นเริ่มฟังการคลิก
updateVisuals()
cd.MouseClick:Connect(onToggle)

AssemblyAngularVelocity
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AssemblyAngularVelocity:Vector3

AssemblyCenterOfMass
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AssemblyCenterOfMass:Vector3

AssemblyLinearVelocity
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AssemblyLinearVelocity:Vector3

AssemblyMass
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AssemblyMass:number

AssemblyRootPart
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AssemblyRootPart:BasePart

AudioCanCollide
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.AudioCanCollide:boolean

BackParamA
เลิกใช้แล้ว

BackParamB
เลิกใช้แล้ว

BackSurface
อ่านพร้อมๆ กัน
BasePart.BackSurface:Enum.SurfaceType

BackSurfaceInput
เลิกใช้แล้ว

BottomParamA
เลิกใช้แล้ว

BottomParamB
เลิกใช้แล้ว

BottomSurface
อ่านพร้อมๆ กัน
BasePart.BottomSurface:Enum.SurfaceType

BottomSurfaceInput
เลิกใช้แล้ว

BrickColor
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.BrickColor:BrickColor

brickColor
เลิกใช้แล้ว

CanCollide
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CanCollide:boolean
ตัวอย่างโค้ด
ประตูจาง
-- วางลงในสคริปต์ภายในชิ้นส่วนที่สูง
local part = script.Parent
local OPEN_TIME = 1
-- ตอนนี้ประตูสามารถเปิดได้หรือไม่?
local debounce = false
local function open()
part.CanCollide = false
part.Transparency = 0.7
part.BrickColor = BrickColor.new("ดำ")
end
local function close()
part.CanCollide = true
part.Transparency = 0
part.BrickColor = BrickColor.new("สีน้ำเงินสด")
end
local function onTouch(otherPart)
-- หากประตูเปิดอยู่แล้ว ให้ทำอะไรต่อไปไม่ได้
if debounce then
print("D")
return
end
-- ตรวจสอบว่าถูกสัมผัสโดย Humanoid
local human = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if not human then
print("ไม่ใช่มนุษย์")
return
end
-- ทำการเปิดประตู
debounce = true
open()
task.wait(OPEN_TIME)
close()
debounce = false
end
part.Touched:Connect(onTouch)
close()

CanQuery
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CanQuery:boolean

CanTouch
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CanTouch:boolean

CastShadow
อ่านพร้อมๆ กัน
BasePart.CastShadow:boolean

CenterOfMass
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CenterOfMass:Vector3

CFrame
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CFrame:CFrame
ตัวอย่างโค้ด
การตั้งค่า CFrame ของ Part
local part = script.Parent:WaitForChild("Part")
local otherPart = script.Parent:WaitForChild("OtherPart")
-- รีเซ็ต CFrame ของ part เป็น (0, 0, 0) โดยไม่มีการหมุน。
-- บางครั้งเรียกว่า "CFrame เอกลักษณ์"
part.CFrame = CFrame.new()
-- ตั้งค่าเป็นตำแหน่งเฉพาะ (X, Y, Z)
part.CFrame = CFrame.new(0, 25, 10)
-- เหมือนกับด้านบน แต่ใช้ Vector3 แทน
local point = Vector3.new(0, 25, 10)
part.CFrame = CFrame.new(point)
-- ตั้งค่า CFrame ของ part ให้ไปที่จุดหนึ่ง มองไปที่อีกจุดหนึ่ง
local lookAtPoint = Vector3.new(0, 20, 15)
part.CFrame = CFrame.lookAt(point, lookAtPoint)
-- หมุน CFrame ของ part ด้วย pi/2 เรเดียนตามแกน X ภายใน
part.CFrame = part.CFrame * CFrame.Angles(math.pi / 2, 0, 0)
-- หมุน CFrame ของ part ด้วย 45 องศาตามแกน Y ภายใน
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(45), 0)
-- หมุน CFrame ของ part ด้วย 180 องศาตามแกน Z ทั่วไป (สังเกตลำดับ!)
part.CFrame = CFrame.Angles(0, 0, math.pi) * part.CFrame -- pi เรเดียน เท่ากับ 180 องศา
-- การประกอบ CFrame สองตัวทำได้โดยใช้ * (ตัวดำเนินการคูณ)
part.CFrame = CFrame.new(2, 3, 4) * CFrame.new(4, 5, 6) --> เท่ากับ CFrame.new(6, 8, 10)
-- ไม่เหมือนการคูณเชิงพีชคณิต การประกอบ CFrame ไม่สามารถสลับกันได้: a * b ไม่จำเป็นต้องเท่ากับ b * a!
-- จินตนาการว่า * คือชุดของการกระทำที่ถูกจัดเรียง เรียงลำดับ ตัวอย่างเช่น บรรทัดต่อไปนี้สร้าง CFrame ที่แตกต่างกัน:
-- 1) เลื่อน part 5 หน่วยตามเส้นแกน X。
-- 2) หมุน part 45 องศารอบแกน Y ของมัน。
part.CFrame = CFrame.new(5, 0, 0) * CFrame.Angles(0, math.rad(45), 0)
-- 1) หมุน part 45 องศารอบแกน Y ของมัน。
-- 2) เลื่อน part 5 หน่วยตามเส้นแกน X。
part.CFrame = CFrame.Angles(0, math.rad(45), 0) * CFrame.new(5, 0, 0)
-- ไม่มี "การหาร CFrame" แต่แทนที่อาจทำการ "ทำตรงกันข้าม"。
part.CFrame = CFrame.new(4, 5, 6) * CFrame.new(4, 5, 6):Inverse() --> เท่ากับ CFrame.new(0, 0, 0)
part.CFrame = CFrame.Angles(0, 0, math.pi) * CFrame.Angles(0, 0, math.pi):Inverse() --> เท่ากับ CFrame.Angles(0, 0, 0)
-- วาง part หนึ่งอันสัมพัทธ์กับอีกอัน (ในกรณีนี้ วาง part ของเราไว้ตรงบน otherPart)
part.CFrame = otherPart.CFrame * CFrame.new(0, part.Size.Y / 2 + otherPart.Size.Y / 2, 0)

CollisionGroup
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CollisionGroup:string
ตัวอย่างโค้ด
PhysicsService:RegisterCollisionGroup
local PhysicsService = game:GetService("PhysicsService")
local collisionGroupBall = "CollisionGroupBall"
local collisionGroupDoor = "CollisionGroupDoor"
-- ลงทะเบียนกลุ่มการชน
PhysicsService:RegisterCollisionGroup(collisionGroupBall)
PhysicsService:RegisterCollisionGroup(collisionGroupDoor)
-- กำหนดชิ้นส่วนให้กับกลุ่มการชน
script.Parent.BallPart.CollisionGroup = collisionGroupBall
script.Parent.DoorPart.CollisionGroup = collisionGroupDoor
-- ตั้งกลุ่มให้ไม่สามารถชนกันและตรวจสอบผลลัพธ์
PhysicsService:CollisionGroupSetCollidable(collisionGroupBall, collisionGroupDoor, false)
print(PhysicsService:CollisionGroupsAreCollidable(collisionGroupBall, collisionGroupDoor)) --> false

CollisionGroupId
เลิกใช้แล้ว

Color
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.Color:Color3
ตัวอย่างโค้ด
สีร่างกายสุขภาพตัวละคร
-- วางลงในสคริปต์ภายใน StarterCharacterScripts
-- จากนั้นเล่นเกม และปรับแต่งสุขภาพของตัวละครของคุณ
local char = script.Parent
local human = char.Humanoid
local colorHealthy = Color3.new(0.4, 1, 0.2)
local colorUnhealthy = Color3.new(1, 0.4, 0.2)
local function setColor(color)
for _, child in pairs(char:GetChildren()) do
if child:IsA("BasePart") then
child.Color = color
while child:FindFirstChildOfClass("Decal") do
child:FindFirstChildOfClass("Decal"):Destroy()
end
elseif child:IsA("Accessory") then
child.Handle.Color = color
local mesh = child.Handle:FindFirstChildOfClass("SpecialMesh")
if mesh then
mesh.TextureId = ""
end
elseif child:IsA("Shirt") or child:IsA("Pants") then
child:Destroy()
end
end
end
local function update()
local percentage = human.Health / human.MaxHealth
-- สร้างสีโดยการเปลี่ยนแปลงตามเปอร์เซ็นต์ของสุขภาพของคุณ
-- สีจะเปลี่ยนจาก colorHealthy (100%) ----- > colorUnhealthy (0%)
local color = Color3.new(
colorHealthy.R * percentage + colorUnhealthy.r * (1 - percentage),
colorHealthy.G * percentage + colorUnhealthy.g * (1 - percentage),
colorHealthy.B * percentage + colorUnhealthy.b * (1 - percentage)
)
setColor(color)
end
update()
human.HealthChanged:Connect(update)

CurrentPhysicalProperties
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.CurrentPhysicalProperties:PhysicalProperties

CustomPhysicalProperties
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.CustomPhysicalProperties:PhysicalProperties
ตัวอย่างโค้ด
ตั้งค่า CustomPhysicalProperties
local part = script.Parent
-- สิ่งนี้จะทำให้ part มีน้ำหนักเบาและเด้ง!
local DENSITY = 0.3
local FRICTION = 0.1
local ELASTICITY = 1
local FRICTION_WEIGHT = 1
local ELASTICITY_WEIGHT = 1
local physProperties = PhysicalProperties.new(DENSITY, FRICTION, ELASTICITY, FRICTION_WEIGHT, ELASTICITY_WEIGHT)
part.CustomPhysicalProperties = physProperties

Elasticity
เลิกใช้แล้ว

EnableFluidForces
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.EnableFluidForces:boolean

ExtentsCFrame
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.ExtentsCFrame:CFrame

ExtentsSize
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.ExtentsSize:Vector3

Friction
เลิกใช้แล้ว

FrontParamA
เลิกใช้แล้ว

FrontParamB
เลิกใช้แล้ว

FrontSurface
อ่านพร้อมๆ กัน
BasePart.FrontSurface:Enum.SurfaceType

FrontSurfaceInput
เลิกใช้แล้ว

LeftParamA
เลิกใช้แล้ว

LeftParamB
เลิกใช้แล้ว

LeftSurface
อ่านพร้อมๆ กัน
BasePart.LeftSurface:Enum.SurfaceType

LeftSurfaceInput
เลิกใช้แล้ว

LocalTransparencyModifier
ซ่อนอยู่
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.LocalTransparencyModifier:number

Locked
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Locked:boolean
ตัวอย่างโค้ด
การปลดล็อกแบบวนซ้ำ
-- วางลงใน Script ภายในโมเดลที่คุณต้องการปลดล็อก
local model = script.Parent
-- ฟังก์ชันนี้จะวนซ้ำผ่านลำดับชั้นของโมเดลและปลดล็อก
-- ทุกส่วนที่มันพบ.
local function recursiveUnlock(object)
if object:IsA("BasePart") then
object.Locked = false
end
-- เรียกฟังก์ชันเดียวกันกับลูกของวัตถุ
-- กระบวนการวนซ้ำจะหยุดถ้วงวัตถุไม่มีลูก
for _, child in pairs(object:GetChildren()) do
recursiveUnlock(child)
end
end
recursiveUnlock(model)

Mass
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Mass:number

Massless
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Massless:boolean

Material
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Material:Enum.Material

MaterialVariant
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.MaterialVariant:string

Orientation
ซ่อนอยู่
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Orientation:Vector3
ตัวอย่างโค้ด
เครื่องหมุนส่วน
local part = script.Parent
local INCREMENT = 360 / 20
-- หมุนชิ้นส่วนอย่างต่อเนื่อง
while true do
for degrees = 0, 360, INCREMENT do
-- ตั้งค่าเฉพาะการหมุนในแกน Y
part.Rotation = Vector3.new(0, degrees, 0)
-- วิธีที่ดีกว่านี้คือการตั้งค่า CFrame
--part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, math.rad(degrees), 0)
task.wait()
end
end

PivotOffset
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.PivotOffset:CFrame
ตัวอย่างโค้ด
รีเซ็ตพิวท
local function resetPivot(model)
local boundsCFrame = model:GetBoundingBox()
if model.PrimaryPart then
model.PrimaryPart.PivotOffset = model.PrimaryPart.CFrame:ToObjectSpace(boundsCFrame)
else
model.WorldPivot = boundsCFrame
end
end
resetPivot(script.Parent)
เข็มนาฬิกา
local function createHand(length, width, yOffset)
local part = Instance.new("Part")
part.Size = Vector3.new(width, 0.1, length)
part.Material = Enum.Material.Neon
part.PivotOffset = CFrame.new(0, -(yOffset + 0.1), length / 2)
part.Anchored = true
part.Parent = workspace
return part
end
local function positionHand(hand, fraction)
hand:PivotTo(CFrame.fromEulerAnglesXYZ(0, -fraction * 2 * math.pi, 0))
end
-- สร้างหน้าปัด
for i = 0, 11 do
local dialPart = Instance.new("Part")
dialPart.Size = Vector3.new(0.2, 0.2, 1)
dialPart.TopSurface = Enum.SurfaceType.Smooth
if i == 0 then
dialPart.Size = Vector3.new(0.2, 0.2, 2)
dialPart.Color = Color3.new(1, 0, 0)
end
dialPart.PivotOffset = CFrame.new(0, -0.1, 10.5)
dialPart.Anchored = true
dialPart:PivotTo(CFrame.fromEulerAnglesXYZ(0, (i / 12) * 2 * math.pi, 0))
dialPart.Parent = workspace
end
-- สร้างเข็ม
local hourHand = createHand(7, 1, 0)
local minuteHand = createHand(10, 0.6, 0.1)
local secondHand = createHand(11, 0.2, 0.2)
-- รันนาฬิกา
while true do
local components = os.date("*t")
positionHand(hourHand, (components.hour + components.min / 60) / 12)
positionHand(minuteHand, (components.min + components.sec / 60) / 60)
positionHand(secondHand, components.sec / 60)
task.wait()
end

Position
ซ่อนอยู่
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Position:Vector3

ReceiveAge
ซ่อนอยู่
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.ReceiveAge:number

Reflectance
อ่านพร้อมๆ กัน
BasePart.Reflectance:number

ResizeableFaces
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.ResizeableFaces:Faces
ตัวอย่างโค้ด
การจัดการขนาด
-- วางสคริปต์นี้ในชิ้นส่วน BasePart หลายประเภท เช่น
-- Part, TrussPart, WedgePart, CornerWedgePart, เป็นต้น
local part = script.Parent
-- สร้างวัตถุ handles สำหรับชิ้นส่วนนี้
local handles = Instance.new("Handles")
handles.Adornee = part
handles.Parent = part
-- กำหนดใบหน้าที่ใช้ได้สำหรับการจัดการนี้ด้วยตนเอง
handles.Faces = Faces.new(Enum.NormalId.Top, Enum.NormalId.Front, Enum.NormalId.Left)
-- ทางเลือกใช้ใบหน้าที่ชิ้นส่วนสามารถปรับขนาดได้
-- ถ้าชิ้นส่วนเป็น TrussPart ที่มีขนาดสองมิติ
-- ยาว 2 แล้ว ResizeableFaces จะมีเพียงสอง
-- ใบหน้าที่เปิดใช้งาน สำหรับชิ้นส่วนอื่น ๆ จะเปิดใช้งานทุกใบหน้า
handles.Faces = part.ResizeableFaces

ResizeIncrement
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
BasePart.ResizeIncrement:number

RightParamA
เลิกใช้แล้ว

RightParamB
เลิกใช้แล้ว

RightSurface
อ่านพร้อมๆ กัน
BasePart.RightSurface:Enum.SurfaceType

RightSurfaceInput
เลิกใช้แล้ว

RootPriority
อ่านพร้อมๆ กัน
BasePart.RootPriority:number

Rotation
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Rotation:Vector3

RotVelocity
เลิกใช้แล้ว

Size
ไม่ซ้ำ
อ่านพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart.Size:Vector3
ตัวอย่างโค้ด
ผู้สร้างพีระมิด
local TOWER_BASE_SIZE = 30
local position = Vector3.new(50, 50, 50)
local hue = math.random()
local color0 = Color3.fromHSV(hue, 1, 1)
local color1 = Color3.fromHSV((hue + 0.35) % 1, 1, 1)
local model = Instance.new("Model")
model.Name = "Tower"
for i = TOWER_BASE_SIZE, 1, -2 do
local part = Instance.new("Part")
part.Size = Vector3.new(i, 2, i)
part.Position = position
part.Anchored = true
part.Parent = model
-- เปลี่ยนจาก color0 และ color1
local perc = i / TOWER_BASE_SIZE
part.Color = Color3.new(
color0.R * perc + color1.R * (1 - perc),
color0.G * perc + color1.G * (1 - perc),
color0.B * perc + color1.B * (1 - perc)
)
position = position + Vector3.new(0, part.Size.Y, 0)
end
model.Parent = workspace

SpecificGravity
เลิกใช้แล้ว

TopParamA
เลิกใช้แล้ว

TopParamB
เลิกใช้แล้ว

TopSurface
อ่านพร้อมๆ กัน
BasePart.TopSurface:Enum.SurfaceType

TopSurfaceInput
เลิกใช้แล้ว

Transparency
อ่านพร้อมๆ กัน
BasePart.Transparency:number
ตัวอย่างโค้ด
ประตูจาง
-- วางลงในสคริปต์ภายในชิ้นส่วนที่สูง
local part = script.Parent
local OPEN_TIME = 1
-- ตอนนี้ประตูสามารถเปิดได้หรือไม่?
local debounce = false
local function open()
part.CanCollide = false
part.Transparency = 0.7
part.BrickColor = BrickColor.new("ดำ")
end
local function close()
part.CanCollide = true
part.Transparency = 0
part.BrickColor = BrickColor.new("สีน้ำเงินสด")
end
local function onTouch(otherPart)
-- หากประตูเปิดอยู่แล้ว ให้ทำอะไรต่อไปไม่ได้
if debounce then
print("D")
return
end
-- ตรวจสอบว่าถูกสัมผัสโดย Humanoid
local human = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if not human then
print("ไม่ใช่มนุษย์")
return
end
-- ทำการเปิดประตู
debounce = true
open()
task.wait(OPEN_TIME)
close()
debounce = false
end
part.Touched:Connect(onTouch)
close()

Velocity
เลิกใช้แล้ว

วิธีการ
AngularAccelerationToTorque
การเข้าถึงการจำลองสถานการณ์
BasePart:AngularAccelerationToTorque(
angAcceleration:Vector3, angVelocity:Vector3
พารามิเตอร์
angAcceleration:Vector3
angVelocity:Vector3
ค่าเริ่มต้น: "0, 0, 0"
ส่งค่ากลับ

ApplyAngularImpulse
การเข้าถึงการจำลองสถานการณ์
BasePart:ApplyAngularImpulse(impulse:Vector3):()
พารามิเตอร์
impulse:Vector3
ส่งค่ากลับ
()

ApplyImpulse
การเข้าถึงการจำลองสถานการณ์
BasePart:ApplyImpulse(impulse:Vector3):()
พารามิเตอร์
impulse:Vector3
ส่งค่ากลับ
()

ApplyImpulseAtPosition
การเข้าถึงการจำลองสถานการณ์
BasePart:ApplyImpulseAtPosition(
impulse:Vector3, position:Vector3
):()
พารามิเตอร์
impulse:Vector3
position:Vector3
ส่งค่ากลับ
()

BreakJoints
เลิกใช้แล้ว

breakJoints
เลิกใช้แล้ว

CanCollideWith
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:CanCollideWith(part:BasePart):boolean
พารามิเตอร์
ส่งค่ากลับ

CanSetNetworkOwnership
การเข้าถึงการจำลองสถานการณ์
BasePart:CanSetNetworkOwnership():Tuple
ส่งค่ากลับ
ตัวอย่างโค้ด
ตรวจสอบว่าการเป็นเจ้าของเครือข่ายของ Part สามารถตั้งค่าได้หรือไม่
local part = workspace:FindFirstChild("Part")
if part and part:IsA("BasePart") then
local canSet, errorReason = part:CanSetNetworkOwnership()
if canSet then
print(part:GetFullName() .. "การเป็นเจ้าของเครือข่ายของ Part สามารถเปลี่ยนแปลงได้!")
else
warn("ไม่สามารถเปลี่ยนการเป็นเจ้าของเครือข่ายของ " .. part:GetFullName() .. " เนื่องจาก: " .. errorReason)
end
end

GetClosestPointOnSurface
การเข้าถึงการจำลองสถานการณ์
BasePart:GetClosestPointOnSurface(position:Vector3):Vector3
พารามิเตอร์
position:Vector3
ส่งค่ากลับ

GetConnectedParts
เขียนพร้อมๆ กัน
BasePart:GetConnectedParts(recursive:boolean):{BasePart}
พารามิเตอร์
recursive:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ

GetJoints
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:GetJoints():Instances
ส่งค่ากลับ
Instances

GetMass
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:GetMass():number
ส่งค่ากลับ
ตัวอย่างโค้ด
การหามวลของชิ้นส่วน
local myPart = Instance.new("Part")
myPart.Size = Vector3.new(4, 6, 4)
myPart.Anchored = true
myPart.Parent = workspace
local myMass = myPart:GetMass()
print("มวลของชิ้นส่วนของฉันคือ " .. myMass)

getMass
เลิกใช้แล้ว

GetNetworkOwner
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:GetNetworkOwner():Instance
ส่งค่ากลับ

GetNetworkOwnershipAuto
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:GetNetworkOwnershipAuto():boolean
ส่งค่ากลับ

GetNoCollisionConstraints
การเข้าถึงการจำลองสถานการณ์
BasePart:GetNoCollisionConstraints():Instances
ส่งค่ากลับ
Instances

GetRenderCFrame
เลิกใช้แล้ว

GetRootPart
เลิกใช้แล้ว

GetTouchingParts
การเข้าถึงการจำลองสถานการณ์
BasePart:GetTouchingParts():Instances
ส่งค่ากลับ
Instances

GetVelocityAtPosition
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:GetVelocityAtPosition(position:Vector3):Vector3
พารามิเตอร์
position:Vector3
ส่งค่ากลับ

IntersectAsync
ผลตอบแทน
ความสามารถ: CSG
BasePart:IntersectAsync(
parts:Instances, collisionfidelity:Enum.CollisionFidelity, renderFidelity:Enum.RenderFidelity
พารามิเตอร์
parts:Instances
collisionfidelity:Enum.CollisionFidelity
ค่าเริ่มต้น: "Default"
renderFidelity:Enum.RenderFidelity
ค่าเริ่มต้น: "Automatic"
ส่งค่ากลับ

IsGrounded
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
BasePart:IsGrounded():boolean
ส่งค่ากลับ

MakeJoints
เลิกใช้แล้ว

makeJoints
เลิกใช้แล้ว

Resize
การเข้าถึงการจำลองสถานการณ์
BasePart:Resize(
normalId:Enum.NormalId, deltaAmount:number
พารามิเตอร์
normalId:Enum.NormalId
deltaAmount:number
ส่งค่ากลับ

resize
เลิกใช้แล้ว

SetNetworkOwner
การเข้าถึงการจำลองสถานการณ์
BasePart:SetNetworkOwner(playerInstance:Player):()
พารามิเตอร์
playerInstance:Player
ค่าเริ่มต้น: "nil"
ส่งค่ากลับ
()

SetNetworkOwnershipAuto
การเข้าถึงการจำลองสถานการณ์
BasePart:SetNetworkOwnershipAuto():()
ส่งค่ากลับ
()

SubtractAsync
ผลตอบแทน
ความสามารถ: CSG
BasePart:SubtractAsync(
parts:Instances, collisionfidelity:Enum.CollisionFidelity, renderFidelity:Enum.RenderFidelity
พารามิเตอร์
parts:Instances
collisionfidelity:Enum.CollisionFidelity
ค่าเริ่มต้น: "Default"
renderFidelity:Enum.RenderFidelity
ค่าเริ่มต้น: "Automatic"
ส่งค่ากลับ
ตัวอย่างโค้ด
BasePart:SubtractAsync()
local Workspace = game:GetService("Workspace")
local mainPart = script.Parent.PartA
local otherParts = { script.Parent.PartB, script.Parent.PartC }
-- ทำการลบ
local success, newSubtract = pcall(function()
return mainPart:SubtractAsync(otherParts)
end)
-- หากการดำเนินการสำเร็จ ให้วางมันไว้ที่ตำแหน่งเดิมและกำหนดให้เป็นลูกของ workspace
if success and newSubtract then
newSubtract.Position = mainPart.Position
newSubtract.Parent = Workspace
end
-- ทำลายชิ้นส่วนเดิมที่ยังคงอยู่หลังจากการดำเนินการ
mainPart:Destroy()
for _, part in otherParts do
part:Destroy()
end

TorqueToAngularAcceleration
การเข้าถึงการจำลองสถานการณ์
BasePart:TorqueToAngularAcceleration(
torque:Vector3, angVelocity:Vector3
พารามิเตอร์
torque:Vector3
angVelocity:Vector3
ค่าเริ่มต้น: "0, 0, 0"
ส่งค่ากลับ

UnionAsync
ผลตอบแทน
ความสามารถ: CSG
BasePart:UnionAsync(
parts:Instances, collisionfidelity:Enum.CollisionFidelity, renderFidelity:Enum.RenderFidelity
พารามิเตอร์
parts:Instances
collisionfidelity:Enum.CollisionFidelity
ค่าเริ่มต้น: "Default"
renderFidelity:Enum.RenderFidelity
ค่าเริ่มต้น: "Automatic"
ส่งค่ากลับ
ตัวอย่างโค้ด
BasePart:UnionAsync()
local Workspace = game:GetService("Workspace")
local mainPart = script.Parent.PartA
local otherParts = { script.Parent.PartB, script.Parent.PartC }
-- ดำเนินการรวม
local success, newUnion = pcall(function()
return mainPart:UnionAsync(otherParts)
end)
-- ถ้าการดำเนินการสำเร็จ ให้ตั้งอยู่ที่ตำแหน่งเดียวกันและเป็นบิดาของ workspace
if success and newUnion then
newUnion.Position = mainPart.Position
newUnion.Parent = Workspace
end
-- ทำลายชิ้นส่วนดั้งเดิมที่ยังคงไม่เสียหายหลังจากการดำเนินการ
mainPart:Destroy()
for _, part in otherParts do
part:Destroy()
end

เหตุการณ์
LocalSimulationTouched
เลิกใช้แล้ว

OutfitChanged
เลิกใช้แล้ว

StoppedTouching
เลิกใช้แล้ว

Touched
BasePart.Touched(otherPart:BasePart):RBXScriptSignal
พารามิเตอร์
otherPart:BasePart
ตัวอย่างโค้ด
จำนวนชิ้นส่วนที่สัมผัส
local part = script.Parent
local billboardGui = Instance.new("BillboardGui")
billboardGui.Size = UDim2.new(0, 200, 0, 50)
billboardGui.Adornee = part
billboardGui.AlwaysOnTop = true
billboardGui.Parent = part
local tl = Instance.new("TextLabel")
tl.Size = UDim2.new(1, 0, 1, 0)
tl.BackgroundTransparency = 1
tl.Parent = billboardGui
local numTouchingParts = 0
local function onTouch(otherPart)
print("การสัมผัสเริ่มต้น: " .. otherPart.Name)
numTouchingParts = numTouchingParts + 1
tl.Text = numTouchingParts
end
local function onTouchEnded(otherPart)
print("การสัมผัสสิ้นสุด: " .. otherPart.Name)
numTouchingParts = numTouchingParts - 1
tl.Text = numTouchingParts
end
part.Touched:Connect(onTouch)
part.TouchEnded:Connect(onTouchEnded)
โมเดลที่ถูกสัมผัส
local model = script.Parent
local function onTouched(otherPart)
-- ละเว้นอินสแตนซ์ของโมเดลที่สัมผัสกับตัวเอง
if otherPart:IsDescendantOf(model) then
return
end
print(model.Name .. " ได้ชนกับ " .. otherPart.Name)
end
for _, child in pairs(model:GetChildren()) do
if child:IsA("BasePart") then
child.Touched:Connect(onTouched)
end
end

TouchEnded
BasePart.TouchEnded(otherPart:BasePart):RBXScriptSignal
พารามิเตอร์
otherPart:BasePart
ตัวอย่างโค้ด
จำนวนชิ้นส่วนที่สัมผัส
local part = script.Parent
local billboardGui = Instance.new("BillboardGui")
billboardGui.Size = UDim2.new(0, 200, 0, 50)
billboardGui.Adornee = part
billboardGui.AlwaysOnTop = true
billboardGui.Parent = part
local tl = Instance.new("TextLabel")
tl.Size = UDim2.new(1, 0, 1, 0)
tl.BackgroundTransparency = 1
tl.Parent = billboardGui
local numTouchingParts = 0
local function onTouch(otherPart)
print("การสัมผัสเริ่มต้น: " .. otherPart.Name)
numTouchingParts = numTouchingParts + 1
tl.Text = numTouchingParts
end
local function onTouchEnded(otherPart)
print("การสัมผัสสิ้นสุด: " .. otherPart.Name)
numTouchingParts = numTouchingParts - 1
tl.Text = numTouchingParts
end
part.Touched:Connect(onTouch)
part.TouchEnded:Connect(onTouchEnded)

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ