BasePart 는 세계 내 개체를 렌더링하고 물리적으로 시뮬레이션하는 동안 추상 기본 클래스입니다. Workspace 에 있습니다.가장 일반적인 구현은 BasePart 와 Part 및 MeshPart 입니다.다른 사람들에는 WedgePart , SpawnLocation 및 단일тон 객체 Terrain 가 포함됩니다.일반적으로 문서가 "부분"을 언급할 때, 대부분의 BasePart 구현은 작동하고 단순히 Part 만 작동하지 않습니다.
시뮬레이션된 단단한 몸으로 그룹화되는 방법에 대한 자세한 정보는 조립을 참조하십시오.
다음을 포함하여 다양한 개체가 BasePart (Terrain)와 상호작용합니다:
- A 는 부품의 표면에 렌더링됩니다. 참조하십시오 경험 내 UI 컨테이너.
- Attachments 는 부품과 관련하여 BasePart 에 추가될 수 있으며, CFrames 을 지정합니다.이는 종종 메커니컬 제약조건 및 이동 제약조건에 설명된 물리적 개체에 의해 사용됩니다.
- 와 같은 경량 개체는 조명 원천에서 중앙에서 조명을 방출합니다. 에 나와 있는 것처럼 조명 소스에서.
- 부모가 에 지정되고 이름 핸들 이 지정되면 캐릭터가 를 보유할 수 있습니다. 경험 도구 참조 경험 도구 참조 .
요약
속성
부품이 물리적으로 이동할 수 없는지 여부를 결정합니다.
부품 조립의 각속도.
세계 공간에서 부품의 질량 중심.
부품 조립의 선형 속도.
부품 조립의 총 질량.
어셈블리의 루트 부분에 대한 참조.
부품의 뒷면 표면 유형을 결정합니다(+Z 방향).
부품의 하단 면에 대한 표면 유형을 결정합니다 (-Y 방향).
부품의 색상을 결정합니다.
세계에서 BasePart 의 위치와 방향을 결정합니다.
부품이 다른 부품과 충돌할 수 있는지 여부를 결정합니다.
부품이 공간 쿼리 작업 중에 고려되는지 여부를 결정합니다.
부품에서 Touched 및 TouchEnded 이벤트가 발생하는지 여부를 결정합니다.
부품이 그림자를 캐스팅하는지 여부를 결정합니다.
부품의 질량 중심이 위치한 세계 위치를 설명합니다.
부품의 충돌 그룹 이름을 설명합니다.
부품의 색상을 결정합니다.
부품의 현재 물리적 속성을 나타냅니다.
부품의 물리적 속성을 여러 가지 결정합니다.
부품과 조립에서 공기역학 힘을 활성화하거나 비활성화하는 데 사용됩니다.
물리 엔진에서 보는 BasePart의 실제 크기.
부품의 앞면 표면 유형을 결정합니다 (-Z 방향).
부품의 왼쪽 면에 대한 표면 유형을 결정합니다 (-X 방향).
로컬 클라이언트에만 표시되는 BasePart.Transparency의 배수를 결정합니다.
부품이 Studio에서 선택 가능한지 여부를 결정합니다.
부품의 질량, 밀도와 용량의 곱을 설명합니다. Describes the mass of the part, the product of its density and volume.
부품이 단단한 신체총 질량이나 중력에 기여하는지 여부를 결정합니다.
부품의 텍스처와 기본 물리적 속성을 결정합니다.
이름 의 MaterialVariant .
세계에서 부품의 회전을 설명합니다.
부품의 피벗 오프셋을 부품의 CFrame에서 지정합니다.
세계에서 부품의 위치를 설명합니다.
마지막으로 기록된 물리 업데이트 이후 시간.
부품이 하늘상자를 얼마나 반영하는지 결정합니다.
Resize 메서드에서 허용하는 가장 작은 크기 변경을 설명합니다.
부품을 재설정할 수 있는 얼굴을 설명합니다.
부품의 오른쪽 면에 대한 표면 유형을 결정합니다 (+X 방향).
어셈블리의 루트 부분을 결정하는 주 규칙.
세 축에 대한 부품의 회전 정도(도).
부품의 차원(길이, 너비, 높이)을 결정합니다.
부품의 상단 면에 대한 표면 유형을 결정합니다(+Y 방향).
부품을 얼마나 볼 수 있는지 결정합니다(부품 불투명도의 반대).
메서드
어셈블리에 각진 펄스를 적용합니다.
조립의 center of mass에 임펄스를 적용하여 조립에 적용합니다.
지정된 위치에 임펄스를 조립에 적용합니다.
부품이 서로 충돌할 수 있는지 여부를 반환합니다.
부품의 네트워크 소유권을 설정할 수 있는지 확인합니다.
어떤 종류의 강성 조인으로 개체에 연결된 부품의 테이블을 반환합니다.
이 부분에 연결된 모든 조인 또는 제약 조건을 반환합니다.
Mass 속성의 값을 반환합니다.
이 부분의 네트워크 소유자인 현재 플레이어를 반환하거나 서버의 경우 nil 입니다.
게임 엔진이 이 부분에 대한 네트워크 소유자를 자동으로 결정하면 true를 반환합니다.
부품 집합의 기본 부분을 반환합니다.
이 부분과 교차하는 모든 BasePart.CanCollide 진실한 부품의 테이블을 반환합니다.
이 부품과 관련하여 지정된 위치에서 부품의 선형 속도를 반환합니다.
개체가 장소에 유지될 부품에 연결되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
Studio 크기 조정 도구를 사용하는 것과 마찬가지로 개체의 크기를 변경합니다.
지정된 플레이어를 네트워크 소유자로 설정하여 이 및 모든 연결된 부품에 대해 네트워크 소유권을 부여합니다.
게임 엔진이 부품의 물리학을 처리할 클라이언트 또는 서버 중 하나를 동적으로 결정하게 합니다.
- IntersectAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
부품의 겹치는 기하학과 주어진 배열의 다른 부품에서 새로운 IntersectOperation를 생성합니다.
- SubtractAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
부품에서 지정된 배열에 있는 부품의 기하학을 빼고 새로운 UnionOperation를 부품에서 만듭니다.
- UnionAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
부품에서 새로운 UnionOperation 를 생성하고, 지정된 배열에 있는 부품의 기하학을 더합니다.
PVInstance의 피벗을 가져옵니다.
피벗이 지금 지정된 PVInstance 에 위치하도록 모든 하위 요소 PVInstances 와 함께 변환하여 피벗이 지금 지정된 CFrame 에 위치합니다.
이벤트
물리적 이동의 결과로 부품이 다른 부품에 접촉하지 않게 되면 발생합니다.
물리적 이동의 결과로 부품이 다른 부품에 닿을 때 발생합니다.
속성
Anchored
고정 속성은 부품이 물리적으로 이동할 수 없는지 여부를 결정합니다.활성화되면 부품은 중력, 다른 부품 충돌, 다른 부품 겹치기 또는 기타 물리 관련 원인으로 인해 위치가 결코 변경되지 않습니다.결과적으로 고정된 부품 두 개는 서로에게 결코 BasePart.Touched 이벤트를 발사하지 않습니다.
고정된 부품은 여전히 CFrame 또는 Position 를 변경하여 이동될 수 있으며, 여전히 0보다 큰 AssemblyLinearVelocity 및 AssemblyAngularVelocity 을 가질 수 있습니다.
마지막으로, 고정되지 않은 부품이 고정된 부품과 함께 연결되는 개체(예: Weld)를 통해 연결되면 고정된 것으로 작동합니다.이러한 공동이 깨지면 부품이 다시 물리학의 영향을 받을 수 있습니다.자세한 내용은 조립을 참조하십시오.
고정된 부품에서는 네트워크 소유권을 설정할 수 없습니다.부품의 고정된 상태가 서버에서 변경되면 해당 부품의 네트워크 소유권이 영향을 받습니다.
코드 샘플
local part = script.Parent
-- Create a ClickDetector so we can tell when the part is clicked
local cd = Instance.new("ClickDetector", part)
-- This function updates how the part looks based on its Anchored state
local function updateVisuals()
if part.Anchored then
-- When the part is anchored...
part.BrickColor = BrickColor.new("Bright red")
part.Material = Enum.Material.DiamondPlate
else
-- When the part is unanchored...
part.BrickColor = BrickColor.new("Bright yellow")
part.Material = Enum.Material.Wood
end
end
local function onToggle()
-- Toggle the anchored property
part.Anchored = not part.Anchored
-- Update visual state of the brick
updateVisuals()
end
-- Update, then start listening for clicks
updateVisuals()
cd.MouseClick:Connect(onToggle)
AssemblyAngularVelocity
이 부분의 조립에 대한 각도 속도 벡터. 초당 방향 변화율입니다.
각도 속도는 조립의 모든 지점에서 동일합니다.
직접 속도를 설정하면 비현실적인 움직임이 발생할 수 있습니다.Torque 또는 AngularVelocity 제약 조건을 사용하는 것이 좋으며, 속도를 즉시 변경하려면 BasePart:ApplyAngularImpulse() 을 사용합니다.
부품이 서버에 의해 소유되는 경우, 이 속성은 서버에서 (서버에서 아니면 또는 또는 에 설정된 것으로) 변경해야 합니다.부품이 자동 소유권을 통해 클라이언트에 소유되는 경우, 이 속성은 클라이언트 스크립트 또는 서버 스크립트에서 변경될 수 있습니다; 서버 소유 부품에 대한 클라이언트 스크립트 변경은 영향을 주지 않습니다.
AssemblyCenterOfMass
조립의 모든 부품의 mass 및 position를 통해 계산된 위치.
어셈블리에 고정된 부품이 있는 경우 해당 부품의 중심 질량이 어셈블리의 중심 질량이 되고 어셈블리는 무한한 질량을 갖게 됩니다.
질량의 중심을 알면 조립의 안정성을 유지하는 데 도움이 됩니다.질량 중심에 적용된 힘은 각속 가속을 일으키지 않고 오직 선형입니다.중심 질량이 낮은 어셈블리는 중력의 영향으로 일어서는 시간이 향상됩니다.
AssemblyLinearVelocity
이 부품의 조립 과정의 선형 속도 벡터입니다. 조립의 center of mass 위치 변화 속도입니다.
조립의 중심 질량이 아닌 지점의 속도를 알고 싶다면 BasePart:GetVelocityAtPosition()를 사용하십시오.
직접 속도를 설정하면 비현실적인 움직임이 발생할 수 있습니다.VectorForce 제약 조건을 사용하는 것이 좋으며, 속도를 즉시 변경하려면 BasePart:ApplyImpulse()를 사용합니다.
부품이 서버에 의해 소유되는 경우, 이 속성은 서버에서 (서버에서 아니면 또는 또는 에 설정된 것으로) 변경해야 합니다.부품이 자동 소유권을 통해 클라이언트에 소유되는 경우, 이 속성은 클라이언트 스크립트 또는 서버 스크립트에서 변경될 수 있습니다; 서버 소유 부품에 대한 클라이언트 스크립트 변경은 영향을 주지 않습니다.
AssemblyMass
이 부분의 조립에 있는 모든 parts의 질량의 합계.부품이 Massless 이고 조립의 루트 부품이 아닌 부품은 조립 마스에 기여하지 않습니다.
어셈블리에 고정된 부품이 있는 경우 어셈블리의 질량이 무한으로 간주됩니다.매스가 큰 고정되지 않은 어셈블리 간의 제약 조건과 다른 물리적 상호 작용은 불안정을 일으킬 수 있습니다.
AssemblyRootPart
이 속성은 조립의 루트 부분을 나타내기 위해 자동으로 선택된 BasePart를 나타냅니다.개발자가 GetRootPart()
루트 부분은 조립의 부품 RootPriority를 변경하여 변경할 수 있습니다.
모두 동일한 조립 루트 파트를 공유하는 부품은 동일한 어셈블리에 있습니다.
루트 부품에 대한 자세한 정보는 어셈블리를 참조하십시오.
AudioCanCollide
BackSurface
백서피스 속성은 부품의 +Z 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.BackSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.일부 표면 유형 - 힌지, 모터 및 스테핑 모터 -은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
BottomSurface
바닥 표면 속성은 부품의 -Y 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.BottomSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.일부 표면 유형 - 힌지, 모터 및 스테핑 모터 -은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
BrickColor
BrickColor 속성은 부품의 색상을 결정합니다.부품에 BasePart.Material 가 있으면 재료 텍스처를 렌더링할 때 사용되는 색상도 결정됩니다.색상에 대한 더 많은 제어를 위해 BasePart.Color 속성을 사용할 수 있습니다(이 속성은 Color3의 변형입니다).색상 집합이 설정되어 있으면 이 속성은 가장 가까운 BrickColor를 사용합니다.
부품의 다른 시각적 속성은 BasePart.Transparency 및 BasePart.Reflectance에 의해 결정됩니다.
코드 샘플
local part = script.Parent
-- Create a ClickDetector so we can tell when the part is clicked
local cd = Instance.new("ClickDetector", part)
-- This function updates how the part looks based on its Anchored state
local function updateVisuals()
if part.Anchored then
-- When the part is anchored...
part.BrickColor = BrickColor.new("Bright red")
part.Material = Enum.Material.DiamondPlate
else
-- When the part is unanchored...
part.BrickColor = BrickColor.new("Bright yellow")
part.Material = Enum.Material.Wood
end
end
local function onToggle()
-- Toggle the anchored property
part.Anchored = not part.Anchored
-- Update visual state of the brick
updateVisuals()
end
-- Update, then start listening for clicks
updateVisuals()
cd.MouseClick:Connect(onToggle)
CFrame
CF레임 속성은 세계에서 위치와 방향을 모두 결정합니다.그것은 기하학에서 임의의 참조 위치로 작동하지만 ExtentsCFrame 는 실제 물리 중심의 CFrame을 나타냅니다.
부품에 CF레임 을 설정할 때 다른 연결된 부품도 부품에 대해 이동되지만, 플레이어의 캐릭터를 순간이동할 때와 같이 전체 모델을 이동하려면 PVInstance:PivotTo()을 사용하는 것이 좋습니다.
설정 과는 달리, 설정 는 항상 부품을 정확히 지정된 로 이동합니다; 즉, 서로 겹치는 부품이 없으면 물리 해결기가 겹치는 것을 해결하려고 시도하고 두 부품이 겹치지 않으면 됩니다.
부품의 위치에 관해 추적하기 위해 CFrame , Attachment 가 유용할 수 있습니다.
코드 샘플
local part = script.Parent:WaitForChild("Part")
local otherPart = script.Parent:WaitForChild("OtherPart")
-- Reset the part's CFrame to (0, 0, 0) with no rotation.
-- This is sometimes called the "identity" CFrame
part.CFrame = CFrame.new()
-- Set to a specific position (X, Y, Z)
part.CFrame = CFrame.new(0, 25, 10)
-- Same as above, but use a Vector3 instead
local point = Vector3.new(0, 25, 10)
part.CFrame = CFrame.new(point)
-- Set the part's CFrame to be at one point, looking at another
local lookAtPoint = Vector3.new(0, 20, 15)
part.CFrame = CFrame.lookAt(point, lookAtPoint)
-- Rotate the part's CFrame by pi/2 radians on local X axis
part.CFrame = part.CFrame * CFrame.Angles(math.pi / 2, 0, 0)
-- Rotate the part's CFrame by 45 degrees on local Y axis
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(45), 0)
-- Rotate the part's CFrame by 180 degrees on global Z axis (note the order!)
part.CFrame = CFrame.Angles(0, 0, math.pi) * part.CFrame -- Pi radians is equal to 180 degrees
-- Composing two CFrames is done using * (the multiplication operator)
part.CFrame = CFrame.new(2, 3, 4) * CFrame.new(4, 5, 6) --> equal to CFrame.new(6, 8, 10)
-- Unlike algebraic multiplication, CFrame composition is NOT communitative: a * b is not necessarily b * a!
-- Imagine * as an ORDERED series of actions. For example, the following lines produce different CFrames:
-- 1) Slide the part 5 units on X.
-- 2) Rotate the part 45 degrees around its Y axis.
part.CFrame = CFrame.new(5, 0, 0) * CFrame.Angles(0, math.rad(45), 0)
-- 1) Rotate the part 45 degrees around its Y axis.
-- 2) Slide the part 5 units on X.
part.CFrame = CFrame.Angles(0, math.rad(45), 0) * CFrame.new(5, 0, 0)
-- There is no "CFrame division", but instead simply "doing the inverse operation".
part.CFrame = CFrame.new(4, 5, 6) * CFrame.new(4, 5, 6):Inverse() --> is equal to CFrame.new(0, 0, 0)
part.CFrame = CFrame.Angles(0, 0, math.pi) * CFrame.Angles(0, 0, math.pi):Inverse() --> equal to CFrame.Angles(0, 0, 0)
-- Position a part relative to another (in this case, put our part on top of otherPart)
part.CFrame = otherPart.CFrame * CFrame.new(0, part.Size.Y / 2 + otherPart.Size.Y / 2, 0)
CanCollide
CanCollide는 부품이 다른 부품과 물리적으로 상호작용할지 여부를 결정합니다.비활성화되면 다른 부품이 중단되지 않고 벽을 통과할 수 있습니다.장식에 사용되는 부품은 일반적으로 물리 엔진에서 고려할 필요가 없기 때문에 CanCollide 가 비활성화됩니다.
부품이 BasePart.Anchored 이고 충돌 금지가 비활성화되어 있으면, 세계에서 떨어져서 Workspace.FallenPartsDestroyHeight에 의해 결국 파괴될 수 있습니다.
CanCollide가 비활성화되면 부품이 여전히 BasePart.Touched 이벤트를 발생시킬 수 있습니다(부품을 만지는 다른 부품도 마찬가지).이를 비활성화하려면 BasePart.CanTouch 을 사용할 수 있습니다.
충돌에 대한 자세한 정보는 충돌을 참조하십시오.
코드 샘플
-- Paste into a Script inside a tall part
local part = script.Parent
local OPEN_TIME = 1
-- Can the door be opened at the moment?
local debounce = false
local function open()
part.CanCollide = false
part.Transparency = 0.7
part.BrickColor = BrickColor.new("Black")
end
local function close()
part.CanCollide = true
part.Transparency = 0
part.BrickColor = BrickColor.new("Bright blue")
end
local function onTouch(otherPart)
-- If the door was already open, do nothing
if debounce then
print("D")
return
end
-- Check if touched by a Humanoid
local human = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if not human then
print("not human")
return
end
-- Perform the door opening sequence
debounce = true
open()
task.wait(OPEN_TIME)
close()
debounce = false
end
part.Touched:Connect(onTouch)
close()
CanQuery
CanQuery는 부품이 GetPartBoundsInBox 또는 Raycast와 같은 공간 쿼리 작업에서 고려되는지 여부를 결정합니다.CanCollide 캐뉴쿼리를 비활성화할 때도 CanQuery를 비활성화해야 합니다.이 함수는 CanQuery 및 CanCollide가 거짓인 부품을 결코 포함하지 않습니다.
이 속성 이상으로, 공간 쿼리 함수를 호출할 때 OverlapParams 또는 RaycastParams 개체를 사용하여 지정된 부품의 하위 부품을 제외할 수도 있습니다.
CanTouch
이 속성은 부품에서 Touched 및 TouchEnded 이벤트가 발생하는지 여부를 결정합니다. 이면, 다른 터치 부품도 터치 이벤트가 발생하도록 설정해야 합니다.false 경우 부품에 대한 터치 이벤트를 설정할 수 없으며 이를 시도하면 오류가 발생합니다.마찬가지로, 터치 이벤트가 연결된 후에 속성이 false로 설정되면 이벤트가 연결 해제되고 TouchTransmitter가 제거됩니다.
이 충돌 논리는 충돌 그룹을 존중하도록 설정할 수 있으며 Workspace.TouchesUseCollisionGroups을 통해 설정할 수 있습니다.만약 true , 충돌하지 않는 그룹의 부품은 충돌 및 터치 이벤트를 모두 무시하여 이 속성을 무효로 만듭니다.
성능
이러한 부품은 부품 간 충돌을 계산할 필요가 없으므로 및 를 모두 설정한 부품에 약간의 성능 향상이 있습니다.그러나 여전히 Raycasts 및 OverlapParams 쿼리에 의해 타격을 받을 수 있습니다.
CastShadow
부품이 그림자를 캐스팅하는지 여부를 결정합니다.
이 기능은 성능 향상을 위해 설계되지 않았습니다( 는 아니지만 ).부품이 던지는 그림자를 숨기고 싶은 부분에서만 비활성화해야 합니다.이 속성을 지정된 부품에 대해 비활성화하면 해당 부품에 캐스트된 그림자에 시각적 결함이 발생할 수 있습니다.
CenterOfMass
CenterOfMass 속성은 부품의 중력 중심 위치를 설명하는 로컬 위치를 설명합니다.이것이 단일 부품 조립이면, 이것은 세계 공간에서 로컬로 변환된 AssemblyCenterOfMass입니다.간단한 Parts 에서 질량의 중심은 항상 (0,0,0)입니다.그러나 WedgePart 또는 MeshPart 에 따라 다를 수 있습니다.
CollisionGroup
CollisionGroup 속성은 부품의 충돌 그룹 이름(최대 100자)을 설명합니다.부품은 기본 그룹인 이름이 "Default" 인 그룹에서 시작됩니다.이 값은 비어있을 수 없습니다.
이 속성 자체는 복제되지 않지만 엔진은 내부적으로 다른 개인 속성을 통해 값을 복제하여 이전 버전 호환 문제를 해결합니다.
코드 샘플
local PhysicsService = game:GetService("PhysicsService")
local collisionGroupBall = "CollisionGroupBall"
local collisionGroupDoor = "CollisionGroupDoor"
-- Register collision groups
PhysicsService:RegisterCollisionGroup(collisionGroupBall)
PhysicsService:RegisterCollisionGroup(collisionGroupDoor)
-- Assign parts to collision groups
script.Parent.BallPart.CollisionGroup = collisionGroupBall
script.Parent.DoorPart.CollisionGroup = collisionGroupDoor
-- Set groups as non-collidable with each other and check the result
PhysicsService:CollisionGroupSetCollidable(collisionGroupBall, collisionGroupDoor, false)
print(PhysicsService:CollisionGroupsAreCollidable(collisionGroupBall, collisionGroupDoor)) --> false
Color
색상 속성은 부품의 색상을 결정합니다.부품에 BasePart.Material 가 있으면 재료 텍스처를 렌더링할 때 사용되는 색상도 결정됩니다.이 속성이 설정되면 BasePart.BrickColor는 Color3 값에 가장 가까운 BrickColor를 사용합니다.
부품의 다른 시각적 속성은 BasePart.Transparency 및 BasePart.Reflectance에 의해 결정됩니다.
코드 샘플
-- Paste into a Script within StarterCharacterScripts
-- Then play the game, and fiddle with your character's health
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
-- Create a color by tweening based on the percentage of your health
-- The color goes from 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
현재 물리 속성은 부품의 현재 물리 속성을 나타냅니다.부품당 물리적 속성에 대한 사용자 지정 값, 사용자 지정 재료 및 재료 재정의를 설정할 수 있습니다.엔진은 부품의 유효한 물리적 속성을 결정할 때 더 세분화된 정의를 우선시합니다.다음 목록의 값은 가장 높은 우선순위에서 가장 낮은 우선순위까지 순서가 지정됩니다:
- 부품의 사용자 지정 물리적 속성
- 부품의 사용자 지정 물질의 특정 물리적 속성
- 부품의 재료 재정의의 사용자 지정 물리적 속성
- 부품의 물질 기본 물리적 속성
CustomPhysicalProperties
사용자 지정 물리적 속성을 사용하면 밀도, 마찰 및 탄성과 같은 Part의 다양한 물리적 측면을 사용자 지정할 수 있습니다.
활성화되면 이 속성을 사용하여 이러한 물리적 속성을 구성할 수 있습니다.비활성화되면 이러한 물리적 속성은 부품의 BasePart.Material에 의해 결정됩니다.Enum.Material 페이지에는 다양한 부품 재료의 목록이 포함되어 있습니다.
코드 샘플
local part = script.Parent
-- This will make the part light and bouncy!
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
EnableFluidForces
참여할 때, 그리고 Workspace.FluidForces 가 활성화되어 있을 때, 물리 엔진이 이 BasePart 에서 공기역학 힘을 계산하게 합니다.
ExtentsSize
물리 엔진에서 예를 들어 충돌 감지에서 보는 BasePart의 실제 물리적 크기, 예를 들어 충돌 감지에서 보는 물리 엔진에서 예를 들어 충돌 감지에서 보는 실제 물리적 크기, 예를 들어 충돌 감지에서 보는
FrontSurface
전면 표면 속성은 부품의 -Z 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.FrontSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.힌지, 모터 및 스텝모터를 포함한 일부 표면 유형은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
LeftSurface
LeftSurface 속성은 부품의 -X 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.LeftSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.힌지, 모터 및 스텝모터를 포함한 일부 표면 유형은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
LocalTransparencyModifier
LocalTransparencyModifier 속성은 로컬 클라이언트에만 표시되는 배수인 BasePart.Transparency입니다.클라이언트에서 서버로 복제되지 않으며 플레이어가 첫 인싸 모드로 확대할 때 특정 클라이언트에서 캐릭터의 신체 부분을 볼 수 없는 경우와 같이 부품이 특정 클라이언트에서 렌더링되지 않아야 할 때 유용합니다.
이 속성은 다음 수식을 통해 로컬 부분의 투명도를 조정하고 결과 값은 0과 1 사이에 고정됩니다.
clientTransparency = 1 - ((1 - part.Transparency) * (1 - part.LocalTransparencyModifier))
<th>로컬 투명도 수정자</th><th>서버 측 투명성</th><th>클라이언트 측 투명성</th></tr></thead><tbody><tr><td>0.5</td><td>0</td><td>0.5</td><td>0.5</td></tr><tr><td>0.5</td><td>0.25</td><td>0.5</td><td>0.625</td></tr><tr><td>0.5</td><td>0.5</td><td>0.5</td><td>0.75</td></tr><tr><td>0.5</td><td>0.75</td><td>0.5</td><td>0.875</td></tr><tr><td>0.5</td><td>1</td><td>0.5</td><td>1</td></tr></tbody>
투명성 |
---|
Locked
잠긴 속성은 클릭하여 Roblox Studio에서 part(또는 포함되어 있는 경우 model)가 선택될 수 있는지 여부를 결정합니다.이 속성은 현재 편집되지 않는 환경 모델 내의 부품에서 가장 자주 활성화됩니다.Roblox Studio에는 모델의 모든 부분 후손의 잠금/잠금 해제 모든 도구가 있으며, 한 번에 모든 부분의 잠금 상태를 전환할 수 있습니다.
코드 샘플
-- Paste into a Script within a Model you want to unlock
local model = script.Parent
-- This function recurses through a model's heirarchy and unlocks
-- every part that it encounters.
local function recursiveUnlock(object)
if object:IsA("BasePart") then
object.Locked = false
end
-- Call the same function on the children of the object
-- The recursive process stops if an object has no children
for _, child in pairs(object:GetChildren()) do
recursiveUnlock(child)
end
end
recursiveUnlock(model)
Mass
질량 은 부품의 용량과 밀도의 산술 제품을 설명하는 읽기 전용 속성입니다. 이는 GetMass 함수에 의해 반환됩니다.
- 부품의 밀도는 지정된 경우 Material 또는 CustomPhysicalProperties에 의해 결정됩니다.
Massless
이 속성이 활성화되면 BasePart 는 마스와 인력이 있는 다른 부품에 접합되는 한 조립의 총 질량이나 관성에 기여하지 않습니다.
부품이 AssemblyRootPart에 따라 자체 루트 부품인 경우, 이 부품은 무시되며 여전히 정상적인 부품처럼 조립에 질량과 중력을 기여합니다.질량이 없는 부품은 조립의 모든 부품이 질량이 없는 경우가 아니면 조립 루트 부품이 되어서는 안됩니다.
이것은 자동차의 핸들링이나 간단한 충돌 메시에 영향을 주지 않으면서 선택적 액세서리나 마스레스 렌더 메시가 접합된 간단한 충돌 메시에 접합된 것과 같은 것에 유용할 수 있습니다.
또한 참조하십시오 어셈블리 , 루트 부품이 무엇이고 어떻게 사용하는지 설명하는 기사.
Material
재료 속성을 통해 빌더가 부품의 텍스처와 기본 물리적 속성(BasePart.CustomPhysicalProperties)을 설정할 수 있습니다.기본 플라스틱 재료는 매우 가벼운 텍스처를 가지고 있고, SmoothPlastic 재료는 텍스처가 전체없습니다.DiamondPlate 및 Granite와 같은 일부 재료 텍스처에는 매우 눈에 띄는 텍스처가 있습니다.각 재료의 텍스처는 특히 포일에서 태양광을 다르게 반사합니다.
이 속성을 설정한 다음 BasePart.CustomPhysicalProperties를 활성화하면 재료의 기본 물리적 속성이 사용됩니다.예를 인스턴스, 다이아몬드 플레이트는 매우 밀도가 높은 재료이고 나무는 매우 가볍습니다.부품의 밀도는 지형 물에 떠있을지 여부를 결정합니다.
유리 재료는 중간 그래픽 설정에서 렌더링 행동을 변경합니다.반사(BasePart.Reflectance와 유사)와 시야 왜곡을 적용합니다.효과는 구형 모양의 부품에서 특히 두드러집니다(공 으로 설정 BasePart.Shape).유리 뒤에 있는 반투명 개체와 유리 부품은 보이지 않습니다.
코드 샘플
local part = script.Parent
-- Create a ClickDetector so we can tell when the part is clicked
local cd = Instance.new("ClickDetector", part)
-- This function updates how the part looks based on its Anchored state
local function updateVisuals()
if part.Anchored then
-- When the part is anchored...
part.BrickColor = BrickColor.new("Bright red")
part.Material = Enum.Material.DiamondPlate
else
-- When the part is unanchored...
part.BrickColor = BrickColor.new("Bright yellow")
part.Material = Enum.Material.Wood
end
end
local function onToggle()
-- Toggle the anchored property
part.Anchored = not part.Anchored
-- Update visual state of the brick
updateVisuals()
end
-- Update, then start listening for clicks
updateVisuals()
cd.MouseClick:Connect(onToggle)
MaterialVariant
시스템은 지정된 재료 변형 이름과 입력인스턴스를 검색합니다.일치하는 재료 변형 인스턴스를 성공적으로 찾으면 기본 재료를 대체하기 위해 이 재료 변형 인스턴스를 사용합니다.기본 재료는 내장 재료 또는 MaterialService에 지정된 재료 변형을 재료로 사용할 수 있습니다.
Orientation
Orientation 속성은 Vector3을 사용하여 X, Y 및 Z축을 중심으로 부품의 회전을 도 단위로 설명합니다.회전은 Y → X → Z 순서로 적용됩니다.이는 적절한 유클리드 각도와 달리 작동하며, 대신 타이트-브라이언 각도를 사용하여 회전, 피치 및 롤 을 설명합니다.이 속성이 다른 순서(Z → Y → X)에서 회전을 적용하는 CFrame.Angles() 생성자와 어떻게 다른지 알아두는 것도 좋습니다.부품의 회전을 더 잘 제어하려면 BasePart.CFrame 대신 설정하는 것이 좋습니다.
이 속성을 설정할 때 이 부분에 연결된 모든 Welds 또는 Motor6Ds 속성은 일치하는 C0 또는 C1 속성이 업데이트되어 부품이 연결된 다른 부품과 상대적으로 이동할 수 있도록 허용합니다.
또한 이동 중에 접합 제약 조건이 일시적으로 비활성화되고 다시 활성화됩니다.
코드 샘플
local part = script.Parent
local INCREMENT = 360 / 20
-- Rotate the part continually
while true do
for degrees = 0, 360, INCREMENT do
-- Set only the Y axis rotation
part.Rotation = Vector3.new(0, degrees, 0)
-- A better way to do this would be setting CFrame
--part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, math.rad(degrees), 0)
task.wait()
end
end
PivotOffset
이 속성은 부품의 피벗 오프셋을 지정하며, 는 와 동일합니다.
이는 피벗을 로컬 공간에 위치로 설정하는 데 편리하지만, 부품의 피벗을 세계 공간에 위치로 설정하는 것은 다음과 같이 수행할 수 있습니다.
local Workspace = game:GetService("Workspace")local part = Workspace.BluePartlocal desiredPivotCFrameInWorldSpace = CFrame.new(0, 10, 0)part.PivotOffset = part.CFrame:ToObjectSpace(desiredPivotCFrameInWorldSpace)
코드 샘플
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
-- Create dial
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
-- Create hands
local hourHand = createHand(7, 1, 0)
local minuteHand = createHand(10, 0.6, 0.1)
local secondHand = createHand(11, 0.2, 0.2)
-- Run clock
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
위치 속성은 part를 사용하여 Vector3의 좌표를 설명합니다.부품의 위치 BasePart.CFrame 를 반영하지만 설정할 수도 있습니다.
이 속성을 설정할 때 이 부분에 연결된 모든 Welds 또는 Motor6Ds 속성은 일치하는 C0 또는 C1 속성이 업데이트되어 부품이 연결된 다른 부품과 상대적으로 이동할 수 있도록 허용합니다.
또한 이동 중에 접합 제약 조건이 일시적으로 비활성화되고 다시 활성화됩니다.
ReceiveAge
이는 부품의 물리학이 로컬 클라이언트(또는 서버)에서 마지막으로 업데이트된 시간을 초 단위로 반환합니다.부품에 물리가 없을 때 0을 반환합니다(고정됨)
Reflectance
반사 속성은 하늘상자를 얼마나 반사할지 결정합니다.The Reflectance property determines how much a part reflects the skybox.0의 값은 부품이 전체반사하지 않는다는 것을 나타내고, 1의 값은 부품이 완전히 반사해야 한다는 것을 나타냅니다.
반사는 부품이 완전히 투명한 경우가 아니면 BasePart.Transparency에 영향을 받지 않으며, 이 경우 반사가 전체렌더링되지 않습니다.반사율은 부품의 BasePart.Material에 따라 무시될 수도 있고 무시될 수도 없습니다.
코드 샘플
local part = script.Parent
local pointLight = Instance.new("PointLight")
pointLight.Brightness = 0
pointLight.Range = 12
pointLight.Parent = part
local touchNo = 0
local function blink()
-- Advance touchNo to tell other blink() calls to stop early
touchNo = touchNo + 1
-- Save touchNo locally so we can tell when it changes globally
local myTouchNo = touchNo
for i = 1, 0, -0.1 do
-- Stop early if another blink started
if touchNo ~= myTouchNo then
break
end
-- Update the blink animation
part.Reflectance = i
pointLight.Brightness = i * 2
task.wait(0.05)
end
end
part.Touched:Connect(blink)
ResizeIncrement
ResizeIncrement 속성은 BasePart:Resize() 메서드에서 허용하는 가장 작은 크기 변경을 설명하는 읽기 전용 속성입니다.BasePart 추상 클래스의 구현에 따라 다릅니다.예를 인스턴스, Part 는 이 설정을 1로, TrussPart 는 이 설정을 2로 설정했습니다(개별 트러스 섹션의 크기가 2x2x2이기 때문입니다).
코드 샘플
-- Put this Script in several kinds of BasePart, like
-- Part, TrussPart, WedgePart, CornerWedgePart, etc.
local part = script.Parent
-- Create a handles object for this part
local handles = Instance.new("Handles")
handles.Adornee = part
handles.Parent = part
-- Manually specify the faces applicable for this handle
handles.Faces = Faces.new(Enum.NormalId.Top, Enum.NormalId.Front, Enum.NormalId.Left)
-- Alternatively, use the faces on which the part can be resized.
-- If part is a TrussPart with only two Size dimensions
-- of length 2, then ResizeableFaces will only have two
-- enabled faces. For other parts, all faces will be enabled.
handles.Faces = part.ResizeableFaces
ResizeableFaces
재설정 가능한 얼굴 속성( e 가 아닌 ResizableFaces)은 부품을 재설정할 수 있는 여러 얼굴에 Faces 개체를 사용하는 방법을 설명합니다.For most implementations of BasePart , such as Part 및 WedgePart , 이 속성에는 모든 얼굴이 포함됩니다.그러나, 는 그러한 부품이 2개의 길이 2의 차원을 가져야 하기 때문에 재설정 가능한 얼굴 집합을 2개로만 설정할 것입니다.이 속성은 주로 부품 건설 및 조작을 위한 도구와 함께 사용되며 해당 컨텍스트 외부에서는 거의 사용되지 않습니다.부품에서 크기를 조정할 수 있는 얼굴에만 핸들을 표시하려면 Handles 클래스, Handles.Faces 속성이 있는 클래스는 이 속성과 함께 사용하여 표시할 수 있습니다.
코드 샘플
-- Put this Script in several kinds of BasePart, like
-- Part, TrussPart, WedgePart, CornerWedgePart, etc.
local part = script.Parent
-- Create a handles object for this part
local handles = Instance.new("Handles")
handles.Adornee = part
handles.Parent = part
-- Manually specify the faces applicable for this handle
handles.Faces = Faces.new(Enum.NormalId.Top, Enum.NormalId.Front, Enum.NormalId.Left)
-- Alternatively, use the faces on which the part can be resized.
-- If part is a TrussPart with only two Size dimensions
-- of length 2, then ResizeableFaces will only have two
-- enabled faces. For other parts, all faces will be enabled.
handles.Faces = part.ResizeableFaces
RightSurface
RightSurface 속성은 부품의 +X 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.RightSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.힌지, 모터 및 스텝모터를 포함한 일부 표면 유형은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
RootPriority
이 속성은 루트 부분 정렬에 대한 다른 모든 규칙보다 우선하는 -127과 127 사이의 정수입니다.RootPriority 가 더 높은 부품은 동일한 RootPriority 값을 공유하는 여러 부품 중에서 우선 순위를 차지할 것입니다.When considering multiple parts that are not and which share the same RootPriority value, a part with a higher RootPriority will take priority over those with lower RootPriority.
이 속성을 사용하여 어떤 부분이 조립의 루트 부분인지 제어하고 크기 변경으로 인해 루트 부분이 안정적으로 유지될 수 있습니다.
또한 참조하십시오 어셈블리 , 루트 부품이 무엇이고 어떻게 사용하는지 설명하는 기사.
Rotation
세 축에 대한 부품의 회전 정도(도).
이 속성을 설정할 때 이 부분에 연결된 모든 Welds 또는 Motor6Ds 속성은 일치하는 C0 또는 C1 속성이 업데이트되어 부품이 연결된 다른 부품과 상대적으로 이동할 수 있도록 허용합니다.
또한 이동 중에 접합 제약 조건이 일시적으로 비활성화되고 다시 활성화됩니다.
Size
부품의 속성은 시각적 차원을 결정하지만 물리 엔진에서 사용하는 실제 크기, 예를 들어 충돌 감지 에서는 충돌 감지에 사용됩니다.개별 차원(길이, 너비, 높이)은 0.001만큼 낮고 2048만큼 높을 수 있습니다.0.05보다 작은 크기 차원은 시각적으로 부품 크기가 0.05인 것처럼 표시됩니다.
부품의 크기는 부품의 질량을 결정하며 BasePart:GetMass() 에 의해 사용됩니다. 부품의 Size 는 다양한 다른 개체에 의해 사용됩니다.
- ParticleEmitter 에서 입자가 생성된 영역을 결정합니다.
- BlockMesh 에서 부분적으로 렌더링된 직사각형 프리즘을 결정합니다.
- SpecialMesh 특정 MeshTypes 에 대해, 렌더링된 메시의 크기를 결정하기 위해
- SurfaceLight 에서 조명할 공간을 결정합니다.
코드 샘플
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
-- Tween from color0 and 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
TopSurface
TopSurface 속성은 부품의 +Y 방향에 사용되는 표면 유형을 결정합니다.두 부품의 표면이 서로 옆에 배치되면 그 사이에 공동을 생성할 수 있습니다.모터로 설정되면 BasePart.TopSurfaceInput 모터 조인트가 어떻게 동작해야 하는지 결정합니다.
대부분의 표면 유형은 BasePart.Material 가 플라스틱으로 설정되어 있으면 부품 면에 텍스처를 렌더링합니다.일부 표면 유형 - 힌지, 모터 및 스테핑 모터 -은 대신 3D 장식을 렌더링합니다.이 속성이 속성 창에서 선택되면, 게임 세계에서 SurfaceSelection와 유사하게 강조됩니다.
코드 샘플
local demoPart = script.Parent
-- Create a billboard gui to display what the current surface type is
local billboard = Instance.new("BillboardGui")
billboard.AlwaysOnTop = true
billboard.Size = UDim2.new(0, 200, 0, 50)
billboard.Adornee = demoPart
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0
textLabel.TextColor3 = Color3.new(1, 1, 1) -- White
textLabel.Parent = billboard
billboard.Parent = demoPart
local function setAllSurfaces(part, surfaceType)
part.TopSurface = surfaceType
part.BottomSurface = surfaceType
part.LeftSurface = surfaceType
part.RightSurface = surfaceType
part.FrontSurface = surfaceType
part.BackSurface = surfaceType
end
while true do
-- Iterate through the different SurfaceTypes
for _, enum in pairs(Enum.SurfaceType:GetEnumItems()) do
textLabel.Text = enum.Name
setAllSurfaces(demoPart, enum)
task.wait(1)
end
end
Transparency
투명도 속성은 0에서 1의 비율로 부품의 가시성을 제어하며, 0은 완전히 보이고(불투명), 1의 값은 완전히 보이지 않습니다(전혀 렌더링되지 전체).
BasePart.Reflectance 는 1에 가까운 값으로 설정되면 벽돌의 전체 투명도를 줄일 수 있습니다.
완전히 투명한 부품은 전체렌더링되지 않지만 부분적으로 투명한 개체에는 상당한 렌더링 비용이 듭니다.많은 반투명 부품이 있으면 게임 이행느려질 수 있습니다.
투명한 부품이 겹치면 랜더링 순서가 예측할 수 없게 될 수 있습니다. - 이를 피하기 위해 반투명한 부품을 겹치지 않도록 유지하십시오.
The BasePart.LocalTransparencyModifier 는 로컬 클라이언트에만 표시되는 투명도의 배수입니다.
코드 샘플
-- Paste into a Script inside a tall part
local part = script.Parent
local OPEN_TIME = 1
-- Can the door be opened at the moment?
local debounce = false
local function open()
part.CanCollide = false
part.Transparency = 0.7
part.BrickColor = BrickColor.new("Black")
end
local function close()
part.CanCollide = true
part.Transparency = 0
part.BrickColor = BrickColor.new("Bright blue")
end
local function onTouch(otherPart)
-- If the door was already open, do nothing
if debounce then
print("D")
return
end
-- Check if touched by a Humanoid
local human = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if not human then
print("not human")
return
end
-- Perform the door opening sequence
debounce = true
open()
task.wait(OPEN_TIME)
close()
debounce = false
end
part.Touched:Connect(onTouch)
close()
local function makeXRayPart(part)
-- LocalTransparencyModifier will make parts see-through but only for the local
-- client, and it won't replicate to the server
part.LocalTransparencyModifier = 0.5
end
-- This function uses recursion to search for parts in the game
local function recurseForParts(object)
if object:IsA("BasePart") then
makeXRayPart(object)
end
-- Stop if this object has a Humanoid - we don't want to see-through players!
if object:FindFirstChildOfClass("Humanoid") then
return
end
-- Check the object's children for more parts
for _, child in pairs(object:GetChildren()) do
recurseForParts(child)
end
end
recurseForParts(workspace)
메서드
AngularAccelerationToTorque
매개 변수
반환
ApplyAngularImpulse
이 부품의 조립에 즉시 각도 힘 펄스를 적용하여 조립이 회전하게 합니다.
충격으로부터 결과적으로 발생하는 각속도는 조립의 mass에 의존합니다.따라서 더 커다란 어셈블리를 이동하려면 더 높은 임펄스가 필요합니다.충동은 폭발이나 충돌과 같이 즉시 적용되는 힘을 원하는 경우에 유용합니다.
부품이 서버에 의해 소유되는 경우, 이 함수는 서버에서 호출되어야 합니다(서버에서 아니면 또는 설정된 또는 에서 호출됨).부품이 자동 소유권을 통해 클라이언트에 소유되어 있는 경우, 이 함수는 클라이언트 스크립트에서 호출될 수도 있고 서버 스크립트에서 호출될 수도 있습니다; 서버 소유 부품에 대해 클라이언트 스크립트에서 호출하는 것은 효과가 없습니다.
매개 변수
조립에 적용할 각도 임펄스 벡터.
반환
ApplyImpulse
이 함수는 이 부품의 조립에 즉시 힘 펄스를 적용합니다.
힘은 조립의 center of mass에 적용되므로 결과 이동은 직선일 뿐입니다.
충격으로 인해 발생하는 결과 속도는 조립의 mass에 의존합니다.따라서 더 커다란 어셈블리를 이동하려면 더 높은 임펄스가 필요합니다.충동은 폭발이나 충돌과 같이 즉시 적용되는 힘을 원하는 경우에 유용합니다.
부품이 서버에 의해 소유되는 경우, 이 함수는 서버에서 호출되어야 합니다(서버에서 아니면 또는 설정된 또는 에서 호출됨).부품이 자동 소유권을 통해 클라이언트에 소유되어 있는 경우, 이 함수는 클라이언트 스크립트에서 호출될 수도 있고 서버 스크립트에서 호출될 수도 있습니다; 서버 소유 부품에 대해 클라이언트 스크립트에서 호출하는 것은 효과가 없습니다.
매개 변수
조립에 적용할 선형 임펄스 벡터.
반환
ApplyImpulseAtPosition
이 함수는 세계 공간의 지정된 위치에서 이 부품의 조립에 즉시 힘 파동을 적용합니다.
위치가 조립의 center of mass에 있지 않으면 임펄스가 위치 및 회전 이동을 유발합니다.
충격으로 인해 발생하는 결과 속도는 조립의 mass에 의존합니다.따라서 더 커다란 어셈블리를 이동하려면 더 높은 임펄스가 필요합니다.충동은 개발자가 즉시 적용되는 힘, 즉 폭발이나 충돌을 원하는 경우에 유용합니다.
부품이 서버에 의해 소유되는 경우, 이 함수는 서버에서 호출되어야 합니다(서버에서 아니면 또는 설정된 또는 에서 호출됨).부품이 자동 소유권을 통해 클라이언트에 소유되어 있는 경우, 이 함수는 클라이언트 스크립트에서 호출될 수도 있고 서버 스크립트에서 호출될 수도 있습니다; 서버 소유 부품에 대해 클라이언트 스크립트에서 호출하는 것은 효과가 없습니다.
매개 변수
반환
CanCollideWith
부품이 서로 충돌할 수 있는지 여부를 반환합니다.이 함수는 두 부품의 충돌 그룹을 고려합니다.지정된 부품이 기본 부품이 아닌 경우 이 함수에 오류가 발생합니다.
매개 변수
충돌 가능성을 확인하는 지정된 부품.
반환
부품이 서로 충돌할 수 있는지 여부.
CanSetNetworkOwnership
CanSetNetworkOwnership 함수는 부품의 네트워크 소유권을 설정할 수 있는지 확인합니다.
함수의 반환 값은 오류를 발견하지 않고 BasePart:SetNetworkOwner() 또는 BasePart:SetNetworkOwnershipAuto()를 호출할 수 있는지 여부를 확인합니다.네트워크 소유권을 수정하거나 읽을 수 있으면 진실을 반환하고, 수정할 수 없는 이유를 문자열로 반환합니다.
반환
네트워크 소유권을 수정하거나 읽을 수 있는지 여부와 이유.
코드 샘플
local part = workspace:FindFirstChild("Part")
if part and part:IsA("BasePart") then
local canSet, errorReason = part:CanSetNetworkOwnership()
if canSet then
print(part:GetFullName() .. "'s Network Ownership can be changed!")
else
warn("Cannot change the Network Ownership of " .. part:GetFullName() .. " because: " .. errorReason)
end
end
GetConnectedParts
어떤 종류의 강성 조인으로 개체에 연결된 부품의 테이블을 반환합니다.
recursive가 true이면 이 함수는 기본 부품에 단단히 연결된 조립의 모든 부품을 반환합니다.
강성 관절
조인이 두 부품을 함께 연결할 때 , 조인은 물리학이 완전히 잠겨 있으면 뻣뻣합니다.다음 공동 유형에만 적용됩니다:
매개 변수
반환
GetJoints
이 부분에 연결된 모든 조인 또는 제약 조건을 반환합니다.
반환
부품에 연결된 모든 관절 또는 제약 조건의 배열.
GetMass
GetMass 는 읽기 전용 Mass 속성의 값을 반환합니다.
이 함수는 질량 속성보다 먼저 도입되었으며 이전 버전과의 호환성을 위해 계속 지원됩니다. 질량 속성을 직접 사용해야 합니다.
반환
부품의 질량.
코드 샘플
local myPart = Instance.new("Part")
myPart.Size = Vector3.new(4, 6, 4)
myPart.Anchored = true
myPart.Parent = workspace
local myMass = myPart:GetMass()
print("My part's mass is " .. myMass)
GetNetworkOwner
이 부분의 네트워크 소유자인 현재 플레이어를 반환하거나 서버의 경우 nil 입니다.
반환
이 부분의 네트워크 소유자인 현재 플레이어 또는 서버의 경우 nil.
GetNetworkOwnershipAuto
게임 엔진이 이 부분에 대한 네트워크 소유자를 자동으로 결정하면 true를 반환합니다.
반환
게임 엔진이 이 부분에 대한 네트워크 소유자를 자동으로 결정하는지 여부.
GetNoCollisionConstraints
반환
GetRootPart
어셈블리의 기본 부분을 반환합니다.부품 조립을 이용하여 이동할 때 CFrame .이 기본 부분을 이동하는 것이 중요합니다(이에 따라 연결된 다른 모든 부분도 이동됩니다).자세한 내용은 조립 문서에서 확인할 수 있습니다.
이 함수는 AssemblyRootPart 속성보다 먼저 시작되었으며 이전 버전과의 호환성을 위해 계속 지원되지만 직접 AssemblyRootPart 을 사용해야 합니다.
반환
어셈블리의 기본 부분(함께 연결된 부품 컬렉션).
GetTouchingParts
이 부분과 물리적으로 상호작용하는 모든 부분의 테이블을 반환합니다.부품 자체에 CanCollide가 false로 설정되어 있으면, 이 함수는 부품에 연결된 TouchInterest 개체가 없으면 빈 테이블을 반환합니다(즉, 부품의 터치 이벤트에 무언가가 연결됨).인접하지만 교차하지 않는 부품은 접촉으로 간주되지 않습니다.이 함수는 위에 설명된 유연성을 제공하고 위의 특별한 WorldRoot:GetPartsInPart() 규칙을 피하는 TouchInterest 함수보다 이전합니다.대신 WorldRoot:GetPartsInPart()
반환
이 부품과 교차하고 충돌할 수 있는 모든 부품의 테이블.
GetVelocityAtPosition
이 부품과 관련하여 지정된 위치에서 부품의 선형 속도를 반환합니다.루트 부품이 아닌 조립의 선형 속도를 식별하는 데 사용할 수 있습니다.어셈블리에 각속도가 없으면 선형 속도는 항상 모든 위치에서 동일합니다.
매개 변수
반환
IsGrounded
개체가 장소에 유지될 부품에 연결되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.조립에 Anchored 부품이 있는 경우 다른 모든 부품이 지상됩니다.
반환
개체가 장소에 고정될 부품에 연결되었는지 여부.
Resize
Studio 크기 조정 도구를 사용하는 것과 마찬가지로 개체의 크기를 변경합니다.
매개 변수
크기를 조정할 측면.
지정된 측면에서 성장/수축할 정도.
반환
부품이 크기가 조정되었는지 여부.
SetNetworkOwner
지정된 플레이어를 네트워크 소유자로 설정하여 이 및 모든 연결된 부품에 대해 네트워크 소유권을 부여합니다.플레이어Instance가 nil, 서버는 플레이어가 아니라 소유자가 됩니다.
매개 변수
부품에 대한 네트워크 소유권을 플레이어에 부여하는 중.
반환
SetNetworkOwnershipAuto
게임 엔진이 부품의 물리학을 처리할 클라이언트 또는 서버 중 하나를 동적으로 결정하게 합니다.
반환
TorqueToAngularAcceleration
매개 변수
반환
IntersectAsync
부품과 주어진 배열의 다른 부품의 교차 기하학에서 새로운 IntersectOperation 를 생성합니다.오직 Parts 만 지원되며 Terrain 또는 MeshParts 은 지원되지 않습니다.Clone() 와 비슷하게, 반환된 개체에는 설정된 Parent 이 없습니다.
호출 부분의 다음 속성이 결과의 IntersectOperation에 적용됩니다.
다음 이미지 비교에서 IntersectAsync() 는 파란색 블록이 포함된 테이블을 사용하여 보라색 블록에 호출됩니다.결과 IntersectOperation 는 두 부품의 교차 기하학의 형태로 해결됩니다.

<figcaption>별도 부품</figcaption>

<figcaption>결과 클래스.IntersectOperation</figcaption>
노트
- 성공적인 교차 작업 후에도 원래 부품은 그대로 유지됩니다.대부분의 경우, 원래 부품 전체를 Destroy() 모두 복사하고 반환된 IntersectOperation 를 호출하는 BasePart 와 동일한 위치에 부모로 지정해야 합니다.
- 교차 작업으로 인해 20,000개 이상의 삼각형이 포함된 부품이 생성되면 20,000개의 삼각형으로 간소화됩니다.
매개 변수
교차점에 참여하는 개체.
결과 Enum.CollisionFidelity 에 대한 값 IntersectOperation.
결과 Enum.RenderFidelity 의 값인 PartOperation.
반환
기본 이름 IntersectOperation 을 사용하여 결과가 나타납니다 교차 .
SubtractAsync
부품에서 지정된 배열에 있는 부품의 기하학을 빼고 새로운 UnionOperation를 부품에서 만듭니다.오직 Parts 만 지원되며 Terrain 또는 MeshParts 은 지원되지 않습니다.Clone() 와 비슷하게, 반환된 개체에는 설정된 Parent 이 없습니다.
빼기로 인해 결과 연합이 비어있을 수 없음을 알아두십시오. 작업이 완전히 비어있는 기하학으로 이어지면 실패합니다.
다음 이미지 비교에서 SubtractAsync() 는 보라색 블록이 포함된 테이블을 사용하여 파란색 실린더에 호출됩니다.결과 UnionOperation 는 블록의 기하학을 실린더의 것에서 생략하는 형태로 해결됩니다.

<figcaption>별도 부품</figcaption>

<figcaption>결과 클래스.UnionOperation </figcaption>
매개 변수
뺄셈에 참여하는 개체.
결과 Enum.CollisionFidelity 에 대한 값 UnionOperation.
결과 Enum.RenderFidelity 의 값인 PartOperation.
반환
기본 이름 UnionOperation 으로 결과가 나타납니다 연합 .
코드 샘플
local Workspace = game:GetService("Workspace")
local mainPart = script.Parent.PartA
local otherParts = { script.Parent.PartB, script.Parent.PartC }
-- Perform subtract operation
local success, newSubtract = pcall(function()
return mainPart:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newSubtract then
newSubtract.Position = mainPart.Position
newSubtract.Parent = Workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
for _, part in otherParts do
part:Destroy()
end
UnionAsync
부품에서 새로운 UnionOperation 를 생성하고, 지정된 배열에 있는 부품의 기하학을 더합니다.오직 Parts 만 지원되며 Terrain 또는 MeshParts 은 지원되지 않습니다.Clone() 와 비슷하게, 반환된 개체에는 설정된 Parent 이 없습니다.
호출 부분의 다음 속성이 결과의 UnionOperation에 적용됩니다.
다음 이미지 비교에서 UnionAsync() 는 보라색 실린더가 포함된 테이블을 사용하여 파란색 블록에서 호출됩니다.결과 UnionOperation 는 두 부품의 결합 기하학의 형태로 해결됩니다.

<figcaption>별도 부품</figcaption>

<figcaption>결과 클래스.UnionOperation </figcaption>
노트
- 원래 부품은 성공적인 결합 작업 후에도 그대로 유지됩니다.대부분의 경우, 원래 부품 전체를 Destroy() 모두 복사하고 반환된 UnionOperation 를 호출하는 BasePart 와 동일한 위치에 부모로 지정해야 합니다.
- 연합 작업이 20,000개 이상의 삼각형이 있는 부품을 결과로 내면 20,000개의 삼각형으로 간소화됩니다.
매개 변수
호출 부분과 연합하는 데 참여하는 개체.
결과 Enum.CollisionFidelity 에 대한 값 UnionOperation.
결과 Enum.RenderFidelity 의 값인 PartOperation.
반환
기본 이름 UnionOperation 으로 결과가 나타납니다 연합 .
코드 샘플
local Workspace = game:GetService("Workspace")
local mainPart = script.Parent.PartA
local otherParts = { script.Parent.PartB, script.Parent.PartC }
-- Perform union operation
local success, newUnion = pcall(function()
return mainPart:UnionAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newUnion then
newUnion.Position = mainPart.Position
newUnion.Parent = Workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
for _, part in otherParts do
part:Destroy()
end
이벤트
TouchEnded
부품이 BasePart.Touched와 유사한 조건에서 다른 부품에 더 이상 접촉하지 않을 때 발생합니다.
이 이벤트는 Workspace.TouchesUseCollisionGroups와 함께 작동하여 충돌 그룹이 감지에 대해 인정되는지 여부를 지정합니다.
매개 변수
코드 샘플
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("Touch started: " .. otherPart.Name)
numTouchingParts = numTouchingParts + 1
tl.Text = numTouchingParts
end
local function onTouchEnded(otherPart)
print("Touch ended: " .. otherPart.Name)
numTouchingParts = numTouchingParts - 1
tl.Text = numTouchingParts
end
part.Touched:Connect(onTouch)
part.TouchEnded:Connect(onTouchEnded)
Touched
만진 이벤트는 부품이 다른 부품과 접촉할 때 발생합니다.예를 인스턴스, 파트A 가 파트B 에 부딪히면, PartA.Touched 는 파트B 로 발사하고, PartB.Touched 는 파트A 로 발사합니다.
이 이벤트는 물리적 이동의 결과로만 발생하므로, 부품이 다른 부품과 겹치도록 CFrame 속성이 변경된 경우에는 발생하지 않습니다.이것은 관련된 부품 중 하나 이상이 충돌 시간에 없어야 한다는 것을 의미합니다.
이 이벤트는 Workspace.TouchesUseCollisionGroups와 함께 작동하여 충돌 그룹이 감지에 대해 인정되는지 여부를 지정합니다.
매개 변수
지정된 부품과 접촉한 다른 부품.
코드 샘플
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("Touch started: " .. otherPart.Name)
numTouchingParts = numTouchingParts + 1
tl.Text = numTouchingParts
end
local function onTouchEnded(otherPart)
print("Touch ended: " .. 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)
-- Ignore instances of the model coming in contact with itself
if otherPart:IsDescendantOf(model) then
return
end
print(model.Name .. " collided with " .. otherPart.Name)
end
for _, child in pairs(model:GetChildren()) do
if child:IsA("BasePart") then
child.Touched:Connect(onTouched)
end
end