BasePart

Show Deprecated
Not Creatable
Not Browsable

BasePart is an abstract base class for in-world objects that render and are physically simulated while in the Workspace. There are several implementations of BasePart, the most common being Part and MeshPart. Others include WedgePart, SpawnLocation, and the singleton Terrain object. Generally, when documentation refers to a "part," most BasePart implementations will work and not just Part.

For information on how BaseParts are grouped into simulated rigid bodies, see Assemblies.

There are many different objects that interact with BasePart (other than Terrain), including:

Summary

Properties

Properties inherited from PVInstance

Properties

Methods

Methods inherited from PVInstance

Methods

Properties

Anchored

Read Parallel

Code Samples

Part Anchored Toggle

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

Not Replicated
Read Parallel

AssemblyCenterOfMass

Read Only
Not Replicated
Read Parallel

AssemblyLinearVelocity

Not Replicated
Read Parallel

AssemblyMass

Read Only
Not Replicated
Read Parallel

AssemblyRootPart

Read Only
Not Replicated
Read Parallel

AudioCanCollide

Read Parallel

BackParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BackParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BackSurface

Read Parallel

BackSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BottomParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BottomParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BottomSurface

Read Parallel

BottomSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

BrickColor

Not Replicated
Read Parallel

CFrame

Read Parallel

Code Samples

Setting Part CFrame

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

Read Parallel

Code Samples

Fade Door

-- 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

Read Parallel

CanTouch

Read Parallel

CastShadow

Read Parallel

CenterOfMass

Read Only
Not Replicated
Read Parallel

CollisionGroup

Not Replicated
Read Parallel

Code Samples

PhysicsService:RegisterCollisionGroup

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

CollisionGroupId

Not Replicated
Deprecated
Read Parallel

Color

Not Replicated
Read Parallel

Code Samples

Character Health Body Color

-- 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

Read Only
Not Replicated
Read Parallel

CustomPhysicalProperties

Read Parallel

Code Samples

Set CustomPhysicalProperties

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

Elasticity

Hidden
Not Replicated
Deprecated
Read Parallel

EnableFluidForces

Read Parallel

ExtentsCFrame

Read Only
Not Replicated
Read Parallel

ExtentsSize

Read Only
Not Replicated
Read Parallel

Friction

Hidden
Not Replicated
Deprecated
Read Parallel

FrontParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

FrontParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

FrontSurface

Read Parallel

FrontSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

LeftParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

LeftParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

LeftSurface

Read Parallel

LeftSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

LocalTransparencyModifier

Hidden
Not Replicated
Read Parallel

Locked

Read Parallel

Code Samples

Recursive Unlock

-- 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

Read Only
Not Replicated
Read Parallel

Massless

Read Parallel
Read Parallel

MaterialVariant

Not Replicated
Read Parallel

Orientation

Hidden
Not Replicated
Read Parallel

Code Samples

Part Spinner

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

Read Parallel

Code Samples

Reset Pivot

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)
Clock Hands

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

Hidden
Not Replicated
Read Parallel

ReceiveAge

Hidden
Read Only
Not Replicated
Read Parallel

Reflectance

Read Parallel

ResizeIncrement

Read Only
Not Replicated
Read Parallel

ResizeableFaces

Read Only
Not Replicated
Read Parallel

Code Samples

Resize Handles

-- 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

RightParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

RightParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

RightSurface

Read Parallel

RightSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

RootPriority

Read Parallel

RotVelocity

Hidden
Deprecated
Read Parallel

Code Samples

Rotating a Part with RotVelocity

local RunService = game:GetService("RunService")
local part = Instance.new("Part")
part.Name = "RotatingPart"
part.Position = Vector3.new(0, 1, 0)
part.Parent = workspace
local function renderStepped()
part.RotVelocity = Vector3.new(0, 10, 0)
end
RunService.RenderStepped:Connect(renderStepped)

Rotation

Not Replicated
Read Parallel
Not Replicated
Read Parallel

Code Samples

Pyramid Builder

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

SpecificGravity

Read Only
Not Replicated
Deprecated
Read Parallel

TopParamA

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

TopParamB

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end
Read Parallel

TopSurfaceInput

Hidden
Deprecated
Read Parallel

Code Samples

Motor Control

-- Paste this into a Script inside a part with a Motor SurfaceType
local partMotor = script.Parent
-- Place a brick called "MovingPart" so it is touching the Motor surface
-- For this example, we use TopSurface, TopSurfaceInput, TopParamA and TopParamB
-- However, this will work for all faces (NormalId): Top, Bottom, Left, Right, Front and Back
-- A function to quickly set all surface properties at once
local function setFaceSurfaceInputParams(normalId, surfaceType, inputType, paramA, paramB)
local surfaceName = normalId.Name -- e.g. "Top", "Bottom", etc
-- Syntax Note: in Lua, part.Something is the same as part["Something"]
-- The difference is that the latter allows us to use a string ("Something"), while
-- the former requires use of an identifier (.Something). Below, we build of each the surface
-- properties below by concatenating the surface name with the property postfix.
-- Set "___Surface", eg "TopSurface"
partMotor[surfaceName .. "Surface"] = surfaceType
-- Set "___SurfaceInput", eg "TopSurfaceInput"
partMotor[surfaceName .. "SurfaceInput"] = inputType
-- Set "___ParamA", eg "TopParamA"
partMotor[surfaceName .. "ParamA"] = paramA
-- Set "___ParamB", eg "TopParamB"
partMotor[surfaceName .. "ParamB"] = paramB
end
local normalId = Enum.NormalId.Top
while true do
-- Set to NoInput, where the motor will not operate at all
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.NoInput, 0, 0)
task.wait(1)
-- Set to Constant, where motor rotational velocity = paramB
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Constant, 0, 0.25)
task.wait(2)
-- Set to Sin, where motor rotational velocity = paramA * math.sin(time * paramB)
-- Since we're using pi (~3.14), the frequency of rotation is 1 second (per definition of sine function)
setFaceSurfaceInputParams(normalId, Enum.SurfaceType.Motor, Enum.InputType.Sin, 0.25, math.pi)
task.wait(3)
end

Transparency

Read Parallel

Code Samples

Fade Door

-- 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()

Velocity

Hidden
Deprecated
Read Parallel

Code Samples

Projectile Firing

-- Put this Script in a Part, preferably bullet-shaped :)
local part = script.Parent
part.Shape = Enum.PartType.Ball
part.Size = Vector3.new(2, 2, 2)
part.BrickColor = BrickColor.new("Really black")
part.CanCollide = false
local MY_START_POINT = Vector3.new(0, 50, 0)
local MY_TARGET_POINT = Vector3.new(50, 100, 0)
local TRAVEL_TIME = 1
local ANTI_GRAVITY = 0.5
-- Anti-gravity effect: add a BodyForce to counter gravity
local bf = Instance.new("BodyForce")
bf.Force = Vector3.new(0, workspace.Gravity * part:GetMass() * ANTI_GRAVITY, 0)
bf.Parent = part
local a0 = Instance.new("Attachment")
a0.Position = Vector3.new(1, 0, 0)
a0.Parent = part
local a1 = Instance.new("Attachment")
a1.Position = Vector3.new(-1, 0, 0)
a1.Parent = part
local trail = Instance.new("Trail")
trail.Parent = part
trail.Attachment0 = a0
trail.Attachment1 = a1
trail.FaceCamera = true
trail.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(1, 1),
})
trail.Lifetime = 0.35
local function fire(startPoint, targetPoint)
-- Calculate how far we have to travel
local distance = (targetPoint - startPoint).magnitude
local speed = distance / TRAVEL_TIME
part.CFrame = CFrame.new(startPoint, targetPoint)
-- Shoot the part
part.Velocity = part.CFrame.LookVector * speed
end
while true do
fire(MY_START_POINT, MY_TARGET_POINT)
task.wait(TRAVEL_TIME)
end

brickColor

Not Replicated
Deprecated
Read Parallel

Methods

AngularAccelerationToTorque

Parameters

angAcceleration: Vector3
angVelocity: Vector3
Default Value: "0, 0, 0"

Returns

ApplyAngularImpulse

()

Parameters

impulse: Vector3

Returns

()

ApplyImpulse

()

Parameters

impulse: Vector3

Returns

()

ApplyImpulseAtPosition

()

Parameters

impulse: Vector3
position: Vector3

Returns

()

BreakJoints

()
Deprecated

Returns

()

CanCollideWith

Write Parallel

Parameters

part: BasePart

Returns

CanSetNetworkOwnership


Returns

Code Samples

Check if a Part's Network Ownership Can Be Set

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

GetClosestPointOnSurface

Parameters

position: Vector3

Returns

GetConnectedParts

Instances
Write Parallel

Parameters

recursive: boolean
Default Value: false

Returns

Instances

GetJoints

Instances
Write Parallel

Returns

Instances

GetMass

Write Parallel

Returns

Code Samples

Finding a Part's 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

Write Parallel

Returns

GetNetworkOwnershipAuto

Write Parallel

Returns

GetNoCollisionConstraints

Instances

Returns

Instances

GetRenderCFrame

Deprecated

Returns

GetRootPart

Deprecated
Write Parallel

Returns

GetTouchingParts

Instances

Returns

Instances

GetVelocityAtPosition

Write Parallel

Parameters

position: Vector3

Returns

IntersectAsync

Yields

Parameters

parts: Instances
collisionfidelity: Enum.CollisionFidelity
Default Value: "Default"
renderFidelity: Enum.RenderFidelity
Default Value: "Automatic"

Returns

IsGrounded

Write Parallel

Returns

MakeJoints

()
Deprecated

Returns

()

Resize

Parameters

normalId: Enum.NormalId
deltaAmount: number

Returns

SetNetworkOwner

()

Parameters

playerInstance: Player
Default Value: "nil"

Returns

()

SetNetworkOwnershipAuto

()

Returns

()

SubtractAsync

Yields

Parameters

parts: Instances
collisionfidelity: Enum.CollisionFidelity
Default Value: "Default"
renderFidelity: Enum.RenderFidelity
Default Value: "Automatic"

Returns

Code Samples

BasePart:SubtractAsync()

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

TorqueToAngularAcceleration

Parameters

torque: Vector3
angVelocity: Vector3
Default Value: "0, 0, 0"

Returns

UnionAsync

Yields

Parameters

parts: Instances
collisionfidelity: Enum.CollisionFidelity
Default Value: "Default"
renderFidelity: Enum.RenderFidelity
Default Value: "Automatic"

Returns

Code Samples

BasePart:UnionAsync()

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

breakJoints

()
Deprecated

Returns

()

getMass

Deprecated

Returns

makeJoints

()
Deprecated

Returns

()

resize

Deprecated

Parameters

normalId: Enum.NormalId
deltaAmount: number

Returns

Events

LocalSimulationTouched

Deprecated

Parameters

part: BasePart

Code Samples

BasePart.LocalSimulationTouched

workspace.Part.LocalSimulationTouched:Connect(function(part)
print(part.Name)
end)

OutfitChanged

Deprecated

StoppedTouching

Deprecated

Parameters

otherPart: BasePart

TouchEnded

Parameters

otherPart: BasePart

Code Samples

Touching Parts Count

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

Parameters

otherPart: BasePart

Code Samples

Touching Parts Count

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)
Model Touched

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