Platform ======== Not Creatable The Platform object creates a brick that when touched by a [Player](/docs/reference/engine/classes/Player) will anchor their torso to the brick. This allows for the creation of vehicles that players can stand in and not be flung about the cabin/deck of the vehicle. The Platform is almost identical to the [Seat](/docs/reference/engine/classes/Seat) object, except that instead of sitting down the player will be standing while locked in place. Good for ships. The Platform object is very useful for making people's characters staying in one spot while they move around, such as a ship or truck. When a player touches the Platform a [Weld](/docs/reference/engine/classes/Weld) constraint is created, so they are 'attached' to the Platform and can't move until that weld is broken. It can be removed by hitting the spacebar, when the player jumps to exit the Platform. Summary ------- ### Properties Properties inherited from Part [](#Shape)Shape: [PartType](/docs/reference/engine/enums/PartType) Sets the overall shape of the object. NOT REPLICATED Properties inherited from FormFactorPart [](#FormFactor)FormFactor: [FormFactor](/docs/reference/engine/enums/FormFactor) NOT REPLICATED DEPRECATED [](#formFactor)formFactor: [FormFactor](/docs/reference/engine/enums/FormFactor) HIDDEN NOT REPLICATED DEPRECATED Properties inherited from BasePart [](#Anchored)Anchored: [boolean](/docs/luau/booleans) Determines whether a part is immovable by physics. [](#AssemblyAngularVelocity)AssemblyAngularVelocity: [Vector3](/docs/reference/engine/datatypes/Vector3) The angular velocity of the part's assembly. NOT REPLICATED [](#AssemblyCenterOfMass)AssemblyCenterOfMass: [Vector3](/docs/reference/engine/datatypes/Vector3) The center of mass of the part's assembly in world space. READ ONLY NOT REPLICATED [](#AssemblyLinearVelocity)AssemblyLinearVelocity: [Vector3](/docs/reference/engine/datatypes/Vector3) The linear velocity of the part's assembly. NOT REPLICATED [](#AssemblyMass)AssemblyMass: [number](/docs/luau/numbers) The total mass of the part's assembly. READ ONLY NOT REPLICATED [](#AssemblyRootPart)AssemblyRootPart: [BasePart](/docs/reference/engine/classes/BasePart) A reference to the root part of the assembly. READ ONLY NOT REPLICATED [](#BackParamA)BackParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Back face of a part (+Z direction). HIDDEN DEPRECATED [](#BackParamB)BackParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Back face of a part (+Z direction). HIDDEN DEPRECATED [](#BackSurface)BackSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Back face of a part (+Z direction). [](#BackSurfaceInput)BackSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Back face of a part (+Z direction). HIDDEN DEPRECATED [](#BottomParamA)BottomParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Bottom face of a part (-Y direction). HIDDEN DEPRECATED [](#BottomParamB)BottomParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Bottom face of a part (-Y direction). HIDDEN DEPRECATED [](#BottomSurface)BottomSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Bottom face of a part (-Y direction). [](#BottomSurfaceInput)BottomSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Bottom face of a part (-Y direction). HIDDEN DEPRECATED [](#BrickColor)BrickColor: [BrickColor](/docs/reference/engine/datatypes/BrickColor) Determines the color of a part. NOT REPLICATED [](#CFrame)CFrame: [CFrame](/docs/reference/engine/datatypes/CFrame) Determines the position and orientation of the [BasePart](/docs/reference/engine/classes/BasePart) in the world. [](#CanCollide)CanCollide: [boolean](/docs/luau/booleans) Determines whether a part may collide with other parts. [](#CanQuery)CanQuery: [boolean](/docs/luau/booleans) Determines whether the part is considered during spatial query operations. [](#CanTouch)CanTouch: [boolean](/docs/luau/booleans) Determines if [Touched](/docs/reference/engine/classes/BasePart#Touched) and [TouchEnded](/docs/reference/engine/classes/BasePart#TouchEnded) events fire on the part. [](#CastShadow)CastShadow: [boolean](/docs/luau/booleans) Determines whether or not a part casts a shadow. [](#CenterOfMass)CenterOfMass: [Vector3](/docs/reference/engine/datatypes/Vector3) Describes the world position in which a part's center of mass is located. READ ONLY NOT REPLICATED [](#CollisionGroup)CollisionGroup: [string](/docs/luau/strings) Describes the name of a part's collision group. NOT REPLICATED [](#CollisionGroupId)CollisionGroupId: [number](/docs/luau/numbers) Describes the automatically set ID number of a part's collision group. NOT REPLICATED DEPRECATED [](#Color)Color: [Color3](/docs/reference/engine/datatypes/Color3) Determines the color of a part. NOT REPLICATED [](#CurrentPhysicalProperties)CurrentPhysicalProperties: [PhysicalProperties](/docs/reference/engine/datatypes/PhysicalProperties) Indicates the current physical properties of the part. READ ONLY NOT REPLICATED [](#CustomPhysicalProperties)CustomPhysicalProperties: [PhysicalProperties](/docs/reference/engine/datatypes/PhysicalProperties) Determines several physical properties of a part. [](#Elasticity)Elasticity: [number](/docs/luau/numbers) Used to control the Elasticity of the part, but it no longer does anything. HIDDEN NOT REPLICATED DEPRECATED [](#EnableFluidForces)EnableFluidForces: [boolean](/docs/luau/booleans) Used to enable or disable aerodynamic forces on parts and assemblies. [](#ExtentsCFrame)ExtentsCFrame: [CFrame](/docs/reference/engine/datatypes/CFrame) The [CFrame](/docs/reference/engine/datatypes/CFrame) of the physical extents of the [BasePart](/docs/reference/engine/classes/BasePart). READ ONLY NOT REPLICATED [](#ExtentsSize)ExtentsSize: [Vector3](/docs/reference/engine/datatypes/Vector3) The actual physical size of the [BasePart](/docs/reference/engine/classes/BasePart) as regarded by the physics engine. READ ONLY NOT REPLICATED [](#Friction)Friction: [number](/docs/luau/numbers) Used to control the Friction of the part, but now it no longer does anything. HIDDEN NOT REPLICATED DEPRECATED [](#FrontParamA)FrontParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Front face of a part (-Z direction). HIDDEN DEPRECATED [](#FrontParamB)FrontParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Front face of a part (-Z direction). HIDDEN DEPRECATED [](#FrontSurface)FrontSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Front face of a part (-Z direction). [](#FrontSurfaceInput)FrontSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Front face of a part (-Z direction). HIDDEN DEPRECATED [](#LeftParamA)LeftParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Left face of a part (-Z direction). HIDDEN DEPRECATED [](#LeftParamB)LeftParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Left face of a part (-Z direction). HIDDEN DEPRECATED [](#LeftSurface)LeftSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Left face of a part (-X direction). [](#LeftSurfaceInput)LeftSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Left face of a part (+X direction). HIDDEN DEPRECATED [](#LocalTransparencyModifier)LocalTransparencyModifier: [number](/docs/luau/numbers) Determines a multiplier for [BasePart.Transparency](/docs/reference/engine/classes/BasePart#Transparency) that is only visible to the local client. HIDDEN NOT REPLICATED [](#Locked)Locked: [boolean](/docs/luau/booleans) Determines whether a part is selectable in Studio. [](#Mass)Mass: [number](/docs/luau/numbers) Describes the mass of the part, the product of its density and volume. READ ONLY NOT REPLICATED [](#Massless)Massless: [boolean](/docs/luau/booleans) Determines whether the part contributes to the total mass or inertia of its rigid body. [](#Material)Material: [Material](/docs/reference/engine/enums/Material) Determines the texture and default physical properties of a part. [](#MaterialVariant)MaterialVariant: [string](/docs/luau/strings) The name of [MaterialVariant](/docs/reference/engine/classes/MaterialVariant). NOT REPLICATED [](#Orientation)Orientation: [Vector3](/docs/reference/engine/datatypes/Vector3) Describes the rotation of the part in the world. HIDDEN NOT REPLICATED [](#PivotOffset)PivotOffset: [CFrame](/docs/reference/engine/datatypes/CFrame) Specifies the offset of the part's pivot from its [CFrame](/docs/reference/engine/datatypes/CFrame). [](#Position)Position: [Vector3](/docs/reference/engine/datatypes/Vector3) Describes the position of the part in the world. HIDDEN NOT REPLICATED [](#ReceiveAge)ReceiveAge: [number](/docs/luau/numbers) Time since last recorded physics update. HIDDEN READ ONLY NOT REPLICATED [](#Reflectance)Reflectance: [number](/docs/luau/numbers) Determines how much a part reflects the skybox. [](#ResizeIncrement)ResizeIncrement: [number](/docs/luau/numbers) Describes the smallest change in size allowable by the Resize method. READ ONLY NOT REPLICATED [](#ResizeableFaces)ResizeableFaces: [Faces](/docs/reference/engine/datatypes/Faces) Describes the faces on which a part may be resized. READ ONLY NOT REPLICATED [](#RightParamA)RightParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Right face of a part (-X direction). HIDDEN DEPRECATED [](#RightParamB)RightParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Right face of a part (-X direction). HIDDEN DEPRECATED [](#RightSurface)RightSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Right face of a part (+X direction). [](#RightSurfaceInput)RightSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Right face of a part (-X direction). HIDDEN DEPRECATED [](#RootPriority)RootPriority: [number](/docs/luau/numbers) The main rule in determining the root part of an assembly. [](#RotVelocity)RotVelocity: [Vector3](/docs/reference/engine/datatypes/Vector3) Determines a part's change in orientation over time. HIDDEN DEPRECATED [](#Rotation)Rotation: [Vector3](/docs/reference/engine/datatypes/Vector3) The rotation of the part in degrees for the three axes. NOT REPLICATED [](#Size)Size: [Vector3](/docs/reference/engine/datatypes/Vector3) Determines the dimensions of a part (length, width, height). NOT REPLICATED [](#SpecificGravity)SpecificGravity: [number](/docs/luau/numbers) The ratio of the part's density to the density of water determined by the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material). READ ONLY NOT REPLICATED DEPRECATED [](#TopParamA)TopParamA: [number](/docs/luau/numbers) Determines the first parameter for the SurfaceType on the Top face of a part (+Y direction). HIDDEN DEPRECATED [](#TopParamB)TopParamB: [number](/docs/luau/numbers) Determines the second parameter for the SurfaceType on the Top face of a part (+Y direction). HIDDEN DEPRECATED [](#TopSurface)TopSurface: [SurfaceType](/docs/reference/engine/enums/SurfaceType) Determines the type of surface for the Top face of a part (+Y direction). [](#TopSurfaceInput)TopSurfaceInput: [InputType](/docs/reference/engine/enums/InputType) Determines the kind of input for the Top face of a part (+Y direction). HIDDEN DEPRECATED [](#Transparency)Transparency: [number](/docs/luau/numbers) Determines how much a part can be seen through (the inverse of part opacity). [](#Velocity)Velocity: [Vector3](/docs/reference/engine/datatypes/Vector3) Determines a part's change in position over time. HIDDEN DEPRECATED [](#brickColor)brickColor: [BrickColor](/docs/reference/engine/datatypes/BrickColor) NOT REPLICATED DEPRECATED Properties inherited from PVInstance [](#Origin)Origin: [CFrame](/docs/reference/engine/datatypes/CFrame) NOT REPLICATED NOT SCRIPTABLE [](#Pivot-Offset)Pivot Offset: [CFrame](/docs/reference/engine/datatypes/CFrame) NOT REPLICATED NOT SCRIPTABLE Properties inherited from Instance [](#Archivable)Archivable: [boolean](/docs/luau/booleans) Determines if an [Instance](/docs/reference/engine/classes/Instance) can be cloned using [Instance:Clone()](/docs/reference/engine/classes/Instance#Clone) or saved to file. [](#ClassName)ClassName: [string](/docs/luau/strings) A read-only string representing the class this [Instance](/docs/reference/engine/classes/Instance) belongs to. READ ONLY NOT REPLICATED [](#Name)Name: [string](/docs/luau/strings) A non-unique identifier of the [Instance](/docs/reference/engine/classes/Instance). [](#Parent)Parent: [Instance](/docs/reference/engine/classes/Instance) Determines the hierarchical parent of the [Instance](/docs/reference/engine/classes/Instance). NOT REPLICATED [](#RobloxLocked)RobloxLocked: [boolean](/docs/luau/booleans) A deprecated property that used to protect [CoreGui](/docs/reference/engine/classes/CoreGui) objects. HIDDEN [](#archivable)archivable: [boolean](/docs/luau/booleans) HIDDEN NOT REPLICATED DEPRECATED [](#className)className: [string](/docs/luau/strings) READ ONLY NOT REPLICATED DEPRECATED ### Methods Methods inherited from BasePart [](#ApplyAngularImpulse)ApplyAngularImpulse(impulse: [Vector3](/docs/reference/engine/datatypes/Vector3)): void   * * * Apply an angular impulse to the assembly. [](#ApplyImpulse)ApplyImpulse(impulse: [Vector3](/docs/reference/engine/datatypes/Vector3)): void   * * * Apply an impulse to the assembly at the assembly's [center of mass](/docs/reference/engine/classes/BasePart#AssemblyCenterOfMass). [](#ApplyImpulseAtPosition)ApplyImpulseAtPosition(impulse: [Vector3](/docs/reference/engine/datatypes/Vector3), position: [Vector3](/docs/reference/engine/datatypes/Vector3)): void   * * * Apply an impulse to the assembly at specified position. [](#BreakJoints)BreakJoints(): void  DEPRECATED * * * Breaks any surface connection with any adjacent part, including [Weld](/docs/reference/engine/classes/Weld) and other [JointInstance](/docs/reference/engine/classes/JointInstance). [](#CanCollideWith)CanCollideWith(part: [BasePart](/docs/reference/engine/classes/BasePart)): [boolean](/docs/luau/booleans)   * * * Returns whether the parts can collide with each other. [](#CanSetNetworkOwnership)CanSetNetworkOwnership(): [Tuple](/docs/luau/tuples)   * * * Checks whether you can set a [part](/docs/reference/engine/classes/BasePart)'s network ownership. [](#GetClosestPointOnSurface)GetClosestPointOnSurface(position: [Vector3](/docs/reference/engine/datatypes/Vector3)): [Vector3](/docs/reference/engine/datatypes/Vector3)   * * * [](#GetConnectedParts)GetConnectedParts(recursive: [boolean](/docs/luau/booleans)): [Objects](/docs/luau/tuples)   * * * Returns a table of parts connected to the object by any kind of rigid joint. [](#GetJoints)GetJoints(): [Objects](/docs/luau/tuples)   * * * Return all Joints or Constraints that is connected to this Part. [](#GetMass)GetMass(): [number](/docs/luau/numbers)   * * * Returns the value of the [Mass](/docs/reference/engine/classes/BasePart#Mass) property. [](#GetNetworkOwner)GetNetworkOwner(): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the current player who is the network owner of this part, or nil in case of the server. [](#GetNetworkOwnershipAuto)GetNetworkOwnershipAuto(): [boolean](/docs/luau/booleans)   * * * Returns true if the game engine automatically decides the network owner for this part. [](#GetNoCollisionConstraints)GetNoCollisionConstraints(): [Objects](/docs/luau/tuples)   * * * [](#GetRenderCFrame)GetRenderCFrame(): [CFrame](/docs/reference/engine/datatypes/CFrame)  DEPRECATED * * * OBSOLETE. Returns a CFrame describing where the part is being rendered at. [](#GetRootPart)GetRootPart(): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the base part of an assembly of parts. [](#GetTouchingParts)GetTouchingParts(): [Objects](/docs/luau/tuples)   * * * Returns a table of all [BasePart.CanCollide](/docs/reference/engine/classes/BasePart#CanCollide) true parts that intersect with this part. [](#GetVelocityAtPosition)GetVelocityAtPosition(position: [Vector3](/docs/reference/engine/datatypes/Vector3)): [Vector3](/docs/reference/engine/datatypes/Vector3)   * * * Returns the linear velocity of the part's assembly at the given position relative to this part. [](#IsGrounded)IsGrounded(): [boolean](/docs/luau/booleans)   * * * Returns true if the object is connected to a part that will hold it in place (eg an [BasePart.Anchored](/docs/reference/engine/classes/BasePart#Anchored) part), otherwise returns false. [](#MakeJoints)MakeJoints(): void  DEPRECATED * * * Creates a joint on any side of the object that has a surface ID that can make a joint. [](#Resize)Resize(normalId: [NormalId](/docs/reference/engine/enums/NormalId), deltaAmount: [number](/docs/luau/numbers)): [boolean](/docs/luau/booleans)   * * * Changes the size of an object just like using the Studio resize tool. [](#SetNetworkOwner)SetNetworkOwner(playerInstance: [Player](/docs/reference/engine/classes/Player)): void   * * * Sets the given player as network owner for this and all connected parts. [](#SetNetworkOwnershipAuto)SetNetworkOwnershipAuto(): void   * * * Lets the game engine dynamically decide who will handle the part's physics (one of the clients or the server). [](#breakJoints)breakJoints(): void  DEPRECATED * * * [](#getMass)getMass(): [number](/docs/luau/numbers)  DEPRECATED * * * [](#makeJoints)makeJoints(): void  DEPRECATED * * * [](#resize)resize(normalId: [NormalId](/docs/reference/engine/enums/NormalId), deltaAmount: [number](/docs/luau/numbers)): [boolean](/docs/luau/booleans)  DEPRECATED * * * [](#IntersectAsync)IntersectAsync(parts: [Objects](/docs/luau/tuples), collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity), renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity)): [Instance](/docs/reference/engine/classes/Instance)  YIELDS * * * Creates a new [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) from the overlapping geometry of the part and the other parts in the given array. [](#SubtractAsync)SubtractAsync(parts: [Objects](/docs/luau/tuples), collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity), renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity)): [Instance](/docs/reference/engine/classes/Instance)  YIELDS * * * Creates a new [UnionOperation](/docs/reference/engine/classes/UnionOperation) from the part, minus the geometry occupied by the parts in the given array. [](#UnionAsync)UnionAsync(parts: [Objects](/docs/luau/tuples), collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity), renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity)): [Instance](/docs/reference/engine/classes/Instance)  YIELDS * * * Creates a new [UnionOperation](/docs/reference/engine/classes/UnionOperation) from the part, plus the geometry occupied by the parts in the given array. Methods inherited from PVInstance [](#GetPivot)GetPivot(): [CFrame](/docs/reference/engine/datatypes/CFrame)   * * * Gets the pivot of a [PVInstance](/docs/reference/engine/classes/PVInstance). [](#PivotTo)PivotTo(targetCFrame: [CFrame](/docs/reference/engine/datatypes/CFrame)): void   * * * Transforms the [PVInstance](/docs/reference/engine/classes/PVInstance) along with all of its descendant [PVInstances](/docs/reference/engine/classes/PVInstance) such that the pivot is now located at the specified [CFrame](/docs/reference/engine/datatypes/CFrame). Methods inherited from Instance [](#AddTag)AddTag(tag: [string](/docs/luau/strings)): void   * * * Applies a tag to the instance. [](#ClearAllChildren)ClearAllChildren(): void   * * * This function destroys all of an [Instance](/docs/reference/engine/classes/Instance)'s children. [](#Clone)Clone(): [Instance](/docs/reference/engine/classes/Instance)   * * * Create a copy of an object and all its descendants, ignoring objects that are not [Archivable](/docs/reference/engine/classes/Instance#Archivable). [](#Destroy)Destroy(): void   * * * Sets the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property to nil, locks the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property, disconnects all connections, and calls Destroy on all children. [](#FindFirstAncestor)FindFirstAncestor(name: [string](/docs/luau/strings)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.Name](/docs/reference/engine/classes/Instance#Name) is equal to the given name. [](#FindFirstAncestorOfClass)FindFirstAncestorOfClass(className: [string](/docs/luau/strings)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) is equal to the given className. [](#FindFirstAncestorWhichIsA)FindFirstAncestorWhichIsA(className: [string](/docs/luau/strings)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) for whom [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) returns true for the given className. [](#FindFirstChild)FindFirstChild(name: [string](/docs/luau/strings), recursive: [boolean](/docs/luau/booleans)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) found with the given name. [](#FindFirstChildOfClass)FindFirstChildOfClass(className: [string](/docs/luau/strings)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) whose [ClassName](/docs/reference/engine/classes/Instance#ClassName) is equal to the given className. [](#FindFirstChildWhichIsA)FindFirstChildWhichIsA(className: [string](/docs/luau/strings), recursive: [boolean](/docs/luau/booleans)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) for whom [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) returns true for the given className. [](#FindFirstDescendant)FindFirstDescendant(name: [string](/docs/luau/strings)): [Instance](/docs/reference/engine/classes/Instance)   * * * Returns the first descendant found with the given [Instance.Name](/docs/reference/engine/classes/Instance#Name). [](#GetActor)GetActor(): [Actor](/docs/reference/engine/classes/Actor)   * * * Returns the [Actor](/docs/reference/engine/classes/Actor) associated with the Instance, if any. [](#GetAttribute)GetAttribute(attribute: [string](/docs/luau/strings)): Variant   * * * Returns the attribute which has been assigned to the given name. [](#GetAttributeChangedSignal)GetAttributeChangedSignal(attribute: [string](/docs/luau/strings)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Returns an event that fires when the given attribute changes. [](#GetAttributes)GetAttributes(): [table](/docs/luau/tables)   * * * Returns a dictionary of string → variant pairs for each of the [Instance](/docs/reference/engine/classes/Instance)'s attributes. [](#GetChildren)GetChildren(): [Objects](/docs/luau/tuples)   * * * Returns an array containing all of the [Instance](/docs/reference/engine/classes/Instance)'s children. [](#GetDebugId)GetDebugId(scopeLength: [number](/docs/luau/numbers)): [string](/docs/luau/strings)  NOT BROWSABLE * * * Returns a coded string of the [Instance](/docs/reference/engine/classes/Instance)s DebugId used internally by Roblox. [](#GetDescendants)GetDescendants(): [Array](/docs/luau/tables)  CUSTOM LUA STATE * * * Returns an array containing all of the descendants of the instance. [](#GetFullName)GetFullName(): [string](/docs/luau/strings)   * * * Returns a string describing the [Instance](/docs/reference/engine/classes/Instance)'s ancestry. [](#GetPropertyChangedSignal)GetPropertyChangedSignal(property: [string](/docs/luau/strings)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Get an event that fires when a given property of an object changes. [](#GetTags)GetTags(): [Array](/docs/luau/tables)   * * * Gets an array of all tags applied to the instance. [](#HasTag)HasTag(tag: [string](/docs/luau/strings)): [boolean](/docs/luau/booleans)   * * * Check whether the instance has a given tag. [](#IsA)IsA(className: [string](/docs/luau/strings)): [boolean](/docs/luau/booleans)  CUSTOM LUA STATE * * * Returns true if an [Instance](/docs/reference/engine/classes/Instance)'s class matches or inherits from a given class. [](#IsAncestorOf)IsAncestorOf(descendant: [Instance](/docs/reference/engine/classes/Instance)): [boolean](/docs/luau/booleans)   * * * Returns true if an [Instance](/docs/reference/engine/classes/Instance) is an ancestor of the given descendant. [](#IsDescendantOf)IsDescendantOf(ancestor: [Instance](/docs/reference/engine/classes/Instance)): [boolean](/docs/luau/booleans)   * * * Returns true if an [Instance](/docs/reference/engine/classes/Instance) is a descendant of the given ancestor. [](#Remove)Remove(): void  DEPRECATED * * * Sets the object's Parent to nil, and does the same for all its descendants. [](#RemoveTag)RemoveTag(tag: [string](/docs/luau/strings)): void   * * * Removes a tag from the instance. [](#SetAttribute)SetAttribute(attribute: [string](/docs/luau/strings), value: Variant): void   * * * Sets the attribute with the given name to the given value. [](#WaitForChild)WaitForChild(childName: [string](/docs/luau/strings), timeOut: [number](/docs/luau/numbers)): [Instance](/docs/reference/engine/classes/Instance)  CUSTOM LUA STATE, CAN YIELD * * * Returns the child of the [Instance](/docs/reference/engine/classes/Instance) with the given name. If the child does not exist, it will yield the current thread until it does. [](#children)children(): [Objects](/docs/luau/tuples)  DEPRECATED * * * Returns an array of the object's children. [](#clone)clone(): [Instance](/docs/reference/engine/classes/Instance)  DEPRECATED * * * [](#destroy)destroy(): void  DEPRECATED * * * [](#findFirstChild)findFirstChild(name: [string](/docs/luau/strings), recursive: [boolean](/docs/luau/booleans)): [Instance](/docs/reference/engine/classes/Instance)  DEPRECATED * * * [](#getChildren)getChildren(): [Objects](/docs/luau/tuples)  DEPRECATED * * * [](#isA)isA(className: [string](/docs/luau/strings)): [boolean](/docs/luau/booleans)  DEPRECATED, CUSTOM LUA STATE * * * [](#isDescendantOf)isDescendantOf(ancestor: [Instance](/docs/reference/engine/classes/Instance)): [boolean](/docs/luau/booleans)  DEPRECATED * * * [](#remove)remove(): void  DEPRECATED * * * ### Events Events inherited from BasePart [](#LocalSimulationTouched)LocalSimulationTouched(part: [BasePart](/docs/reference/engine/classes/BasePart)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)  DEPRECATED * * * [](#OutfitChanged)OutfitChanged(): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)  DEPRECATED * * * [](#StoppedTouching)StoppedTouching(otherPart: [BasePart](/docs/reference/engine/classes/BasePart)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)  DEPRECATED * * * [](#TouchEnded)TouchEnded(otherPart: [BasePart](/docs/reference/engine/classes/BasePart)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires when a part stops touching another part as a result of physical movement. [](#Touched)Touched(otherPart: [BasePart](/docs/reference/engine/classes/BasePart)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires when a part touches another part as a result of physical movement. Events inherited from Instance [](#AncestryChanged)AncestryChanged(child: [Instance](/docs/reference/engine/classes/Instance), parent: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires when the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property of the object or one of its ancestors is changed. [](#AttributeChanged)AttributeChanged(attribute: [string](/docs/luau/strings)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires whenever an attribute is changed on the [Instance](/docs/reference/engine/classes/Instance). [](#Changed)Changed(property: [string](/docs/luau/strings)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fired immediately after a property of an object changes. [](#ChildAdded)ChildAdded(child: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires after an object is parented to this [Instance](/docs/reference/engine/classes/Instance). [](#ChildRemoved)ChildRemoved(child: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires after a child is removed from this [Instance](/docs/reference/engine/classes/Instance). [](#DescendantAdded)DescendantAdded(descendant: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires after a descendant is added to the [Instance](/docs/reference/engine/classes/Instance). [](#DescendantRemoving)DescendantRemoving(descendant: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires immediately before a descendant of the [Instance](/docs/reference/engine/classes/Instance) is removed. [](#Destroying)Destroying(): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)   * * * Fires immediately before the instance is destroyed via [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy). [](#childAdded)childAdded(child: [Instance](/docs/reference/engine/classes/Instance)): [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal)  DEPRECATED * * * Properties ---------- Properties inherited from Part ### Shape [PartType](/docs/reference/engine/enums/PartType) Not Replicated [Read Parallel](/docs/scripting/multithreading) The Shape property sets the overall shape of the object to one of a predetermined list of built-in shapes. The [PartType](/docs/reference/engine/enums/PartType) enum controls the shape value, and has five possible shapes: Shape/Value Description Ball A spherical shape, like a basketball. Cylinder A rod-like shape, like a tin can. Block The default, brick shape. Wedge A wedge shape with a slope on one side. CornerWedge A wedge shape with slopes on two sides. Note that [MeshPart](/docs/reference/engine/classes/MeshPart) and [solid modeling](https://prod.docsiteassets.roblox.com/parts/solid-modeling.md) can be used to obtain completely custom part shapes. #### Code Samples The script below spawns a new Part instance and sets several of the part's properties. Most notably, the script sets the [Part.Shape](/docs/reference/engine/classes/Part#Shape) property to [PartType.Ball](/docs/reference/engine/enums/PartType#Ball). It also names the part _JurassicPart_, anchors it, makes it a child of _Workspace_, and sets its color to white. Create a Part in a Script * * * local part = Instance.new("Part") part.Name = "JurassicPart" part.Anchored = true part.Shape = Enum.PartType.Ball part.Color = Color3.new(1, 1, 1) part.Parent = workspace -- Put the part into the Workspace Properties inherited from FormFactorPart ### FormFactor [FormFactor](/docs/reference/engine/enums/FormFactor) Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This property has been deprecated and should not be used in new work. This used to specify a grid constraint of the part's size. No longer does anything. ### formFactor [FormFactor](/docs/reference/engine/enums/FormFactor) Hidden Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This property has been deprecated and should not be used in new work. Determines how a part acts when resized and the values that which its size can take. Properties inherited from BasePart ### Anchored [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) The Anchored property determines whether the part will be immovable by physics. When enabled, a part will never change position due to gravity, other parts collisions, overlapping other parts, or any other physics-related causes. A part that is not anchored is called unanchored. As a result, two anchored parts will never fire the [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched) event on each other. An anchored part may still be moved by changing its [BasePart.CFrame](/docs/reference/engine/classes/BasePart#CFrame) or [BasePart.Position](/docs/reference/engine/classes/BasePart#Position), and it still may have a nonzero [BasePart.AssemblyLinearVelocity](/docs/reference/engine/classes/BasePart#AssemblyLinearVelocity) and [BasePart.AssemblyAngularVelocity](/docs/reference/engine/classes/BasePart#AssemblyAngularVelocity). Finally, if an unanchored part is joined with an anchored part through an object like a [Weld](/docs/reference/engine/classes/Weld), it too will act anchored. If such a joint breaks the part may be affected by physics again. See [Understanding Assemblies](https://prod.docsiteassets.roblox.com/physics/assemblies.md) for more on this. Network ownership cannot be set on anchored parts. If a part's anchored status changes on the server, the network ownership of that part will be affected. #### Code Samples This code sample will allow a part to be clicked to toggle its anchored property. When toggled, the visual appearance of the part is updated (red means anchored, yellow means free). 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 [Vector3](/docs/reference/engine/datatypes/Vector3) Not Replicated [Read Parallel](/docs/scripting/multithreading) The angular velocity vector of this [part](/docs/reference/engine/classes/BasePart)'s assembly. It's the rate of change of orientation in radians per second. Angular velocity is the same at every point of the assembly. Setting the velocity directly may lead to unrealistic motion. Using [Torque](/docs/reference/engine/classes/Torque) or [AngularVelocity](/docs/reference/engine/classes/AngularVelocity) constraint is preferred, or use [BasePart:ApplyAngularImpulse()](/docs/reference/engine/classes/BasePart#ApplyAngularImpulse) if you want instantaneous change in velocity. ### AssemblyCenterOfMass [Vector3](/docs/reference/engine/datatypes/Vector3) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) A position calculated via the [mass](/docs/reference/engine/classes/BasePart#Mass) and [position](/docs/reference/engine/classes/BasePart#Position) of all the parts in the assembly. If the assembly has an anchored part, that part's center of mass will be the assembly's center of mass, and the assembly will have infinite mass. Knowing the center of mass can help the assembly maintain stability. A force applied to the center of mass will not cause angular acceleration, only linear. An assembly with a low center of mass will have a better time staying upright under the effect of gravity. ### AssemblyLinearVelocity [Vector3](/docs/reference/engine/datatypes/Vector3) Not Replicated [Read Parallel](/docs/scripting/multithreading) The linear velocity vector of this [part](/docs/reference/engine/classes/BasePart)'s assembly. It's the rate of change in position of the assembly's [center of mass](/docs/reference/engine/classes/BasePart#AssemblyCenterOfMass) in studs per second. If you want to know the velocity at a point other than the assembly's center of mass, use [BasePart:GetVelocityAtPosition()](/docs/reference/engine/classes/BasePart#GetVelocityAtPosition). Setting the velocity directly may lead to unrealistic motion. Using a [VectorForce](/docs/reference/engine/classes/VectorForce) constraint is preferred, or use [BasePart:ApplyImpulse()](/docs/reference/engine/classes/BasePart#ApplyImpulse) if you want instantaneous change in velocity. ### AssemblyMass [number](/docs/luau/numbers) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The sum of the mass of all the [parts](/docs/reference/engine/classes/BasePart) in this part's assembly. Parts that are [Massless](/docs/reference/engine/classes/BasePart#Massless) and are not the assembly's root part will not contribute to the AssemblyMass. If the assembly has an anchored part, the assembly's mass is considered infinite. Constraints and other physical interactions between unanchored assemblies with a large difference in mass may cause instabilities. ### AssemblyRootPart [BasePart](/docs/reference/engine/classes/BasePart) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) This property indicates the [BasePart](/docs/reference/engine/classes/BasePart) automatically chosen to represent the Assembly|assembly's root part. It is the same part that's returned when developers call [GetRootPart()](/docs/reference/engine/classes/BasePart#GetRootPart). The root part can be changed by changing the [RootPriority](/docs/reference/engine/classes/BasePart#RootPriority) of the parts in the assembly. Parts that all share the same AssemblyRootPart are in the same assembly. For more information on root parts, see [Understanding Assemblies](https://prod.docsiteassets.roblox.com/physics/assemblies.md). ### BackParamA [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BackParamA property is relevant when a part's [BasePart.BackSurface](/docs/reference/engine/classes/BasePart#BackSurface) is set to Motor or SteppingMotor and [BasePart.BackSurfaceInput](/docs/reference/engine/classes/BasePart#BackSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) There are no other usages for this property. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BackParamB property is relevant when a part's [BasePart.BackSurface](/docs/reference/engine/classes/BasePart#BackSurface) is set to Motor or SteppingMotor and [BasePart.BackSurfaceInput](/docs/reference/engine/classes/BasePart#BackSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The BackSurface property determines the type of surface used for the +Z direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.BackSurfaceInput](/docs/reference/engine/classes/BasePart#BackSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes - Hinge, Motor and SteppingMotor - will render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### BackSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BackSurfaceInput property determines the kind of input provided to a part's [BasePart.BackSurface](/docs/reference/engine/classes/BasePart#BackSurface). This is only relevant for Motor or SteppingMotor SurfaceTypes. This property determines how [BasePart.BackParamA](/docs/reference/engine/classes/BasePart#BackParamA) and [BasePart.BackParamB](/docs/reference/engine/classes/BasePart#BackParamB) are used. For brevity, these properties will be referred to as ParamA and ParamB, respectively. * By default, this is set to NoInput. This stops the motor altogether. * For Constant, the motor rotates at a constant velocity equal to ParamB. * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BottomParamA property is relevant when a part's [BasePart.BottomSurface](/docs/reference/engine/classes/BasePart#BottomSurface) is set to Motor or SteppingMotor and [BasePart.BottomSurfaceInput](/docs/reference/engine/classes/BasePart#BottomSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) There are no other usages for this property. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BottomParamB property is relevant when a part's [BasePart.BottomSurface](/docs/reference/engine/classes/BasePart#BottomSurface) is set to Motor or SteppingMotor and [BasePart.BottomSurfaceInput](/docs/reference/engine/classes/BasePart#BottomSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The BottomSurface property determines the type of surface used for the -Y direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.BottomSurfaceInput](/docs/reference/engine/classes/BasePart#BottomSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes - Hinge, Motor and SteppingMotor - will render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### BottomSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The BottomSurfaceInput property determines the kind of input provided to a part's [BasePart.BottomSurface](/docs/reference/engine/classes/BasePart#BottomSurface). This is only relevant for Motor or SteppingMotor SurfaceTypes. This property determines how [BasePart.BottomParamA](/docs/reference/engine/classes/BasePart#BottomParamA) and [BasePart.BottomParamB](/docs/reference/engine/classes/BasePart#BottomParamB) are used. For brevity, these properties will be referred to as ParamA and ParamB, respectively. * By default, this is set to NoInput. This stops the motor altogether. * For Constant, the motor rotates at a constant velocity equal to ParamB. * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [BrickColor](/docs/reference/engine/datatypes/BrickColor) Not Replicated [Read Parallel](/docs/scripting/multithreading) The BrickColor property determines the color of a part. If the part has a [BasePart.Material](/docs/reference/engine/classes/BasePart#Material), this also determines the color used when rendering the material texture. For more control over the color, the [BasePart.Color](/docs/reference/engine/classes/BasePart#Color) property can be used (it is a Color3 variant of this property). If Color set, this property will use the closest BrickColor. Other visual properties of a part are determined by [BasePart.Transparency](/docs/reference/engine/classes/BasePart#Transparency) and [BasePart.Reflectance](/docs/reference/engine/classes/BasePart#Reflectance). #### Code Samples This code sample will allow a part to be clicked to toggle its anchored property. When toggled, the visual appearance of the part is updated (red means anchored, yellow means free). 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) ### CFrame [CFrame](/docs/reference/engine/datatypes/CFrame) [Read Parallel](/docs/scripting/multithreading) The CFrame property determines both the position and orientation of the [BasePart](/docs/reference/engine/classes/BasePart) in the world. It acts as an arbitrary reference location on the geometry, but [ExtentsCFrame](/docs/reference/engine/classes/BasePart#ExtentsCFrame) represents the actual [CFrame](/docs/reference/engine/datatypes/CFrame) of its physical center. When setting CFrame on a part, other joined parts are also moved relative to the part, but it is recommended that you use [PVInstance:PivotTo()](/docs/reference/engine/classes/PVInstance#PivotTo) to move an entire model, such as when teleporting a player's character. Unlike setting [BasePart.Position](/docs/reference/engine/classes/BasePart#Position), setting [BasePart.CFrame](/docs/reference/engine/classes/BasePart#CFrame) will always move the part to the exact given [CFrame](/docs/reference/engine/datatypes/CFrame); in other words: no overlap checking is done and the physics solver will attempt to resolve any overlap unless both parts are [Anchored](/docs/reference/engine/classes/BasePart#Anchored). For keeping track of positions relative to a part's [CFrame](/docs/reference/engine/datatypes/CFrame), an [Attachment](/docs/reference/engine/classes/Attachment) may be useful. #### Code Samples This code sample demonstrates setting a part's CFrame in many different ways. It showcases how to create and compose CFrame values. It references a sibling part called "OtherPart" for demonstrating relative positioning. Setting Part CFrame * * * local part = script.Parent -- 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.new(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) -- A reference to some other part local otherPart = part.Parent.OtherPart -- 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) -- All of this information applies to SetPrimaryPartCFrame, since that's all tht method local model = part.Parent.Model model:SetPrimaryPartCFrame(CFrame.new(0, 25, 0)) ### CanCollide [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) CanCollide determines whether a part will physically interact with other parts. When disabled, other parts can pass through the brick uninterrupted. Parts used for decoration usually have CanCollide disabled, as they need not be considered by the physics engine. If a part is not [BasePart.Anchored](/docs/reference/engine/classes/BasePart#Anchored) and has CanCollide disabled, it may fall out of the world to be eventually destroyed by [Workspace.FallenPartsDestroyHeight](/docs/reference/engine/classes/Workspace#FallenPartsDestroyHeight). When CanCollide is disabled, parts may still fire the [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched) event (as well the other parts touching them). You can disable this with [BasePart.CanTouch](/docs/reference/engine/classes/BasePart#CanTouch). For more information on collisions, see [Collisions](https://prod.docsiteassets.roblox.com/workspace/collisions.md). #### Code Samples This code sample shows how a part can fade away when touched by a Humanoid then reappear a moment after to create a passable door. 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 [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) CanQuery determines whether the part is considered during spatial query operations, such as [GetPartBoundsInBox](/docs/reference/engine/classes/WorldRoot#GetPartBoundsInBox) or [Raycast](/docs/reference/engine/classes/WorldRoot#Raycast). CanCollide must also be disabled when disabling CanQuery. These functions will never include parts whose CanQuery and CanCollide is false. Beyond this property, it is also possible to exclude parts which are descendants of a given list of parts using an [OverlapParams](/docs/reference/engine/datatypes/OverlapParams) or [RaycastParams](/docs/reference/engine/datatypes/RaycastParams) object when calling the spatial query functions. ### CanTouch [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) This property determines if [Touched](/docs/reference/engine/classes/BasePart#Touched) and [TouchEnded](/docs/reference/engine/classes/BasePart#TouchEnded) events fire on the part. If true, other touching parts must also have [CanTouch](/docs/reference/engine/classes/BasePart#CanTouch) set to true for touch events to fire. If false, touch events cannot be set up for the part and attempting to do so will throw an error. Similarly, if the property is set to false after a touch event is connected, the event will be disconnected and the [TouchTransmitter](/docs/reference/engine/classes/TouchTransmitter) removed. Note that this collision logic can be set to respect [collision groups](/docs/workspace/collisions.md#collision-filtering) through the [Workspace.TouchesUseCollisionGroups](/docs/reference/engine/classes/Workspace#TouchesUseCollisionGroups) property. If true, parts in non-colliding groups will ignore both collisions and touch events, thereby making this property irrelevant. #### Performance There is a small performance gain on parts that have both [CanTouch](/docs/reference/engine/classes/BasePart#CanTouch) and [CanCollide](/docs/reference/engine/classes/BasePart#CanCollide) set to false, as these parts will never need to compute any kind of part to part collisions. However, they can still be hit by [Raycasts](/docs/reference/engine/classes/WorldRoot#Raycast) and [OverlapParams](/docs/reference/engine/datatypes/OverlapParams) queries. ### CastShadow [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) Determines whether or not a part casts a shadow. Note that this feature is not designed for performance enhancement. It should only be disabled on parts where you want to hide the shadows the part casts. Disabling this property for a given part may cause visual artifacts on the shadows cast upon that part. ### CenterOfMass [Vector3](/docs/reference/engine/datatypes/Vector3) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The CenterOfMass property describes the local position of a [part](/docs/reference/engine/classes/BasePart)'s center of mass. If this is a single part assembly, this is the AssemblyCenterOfMass converted from world space to local. On simple [Parts](/docs/reference/engine/classes/Part), the center of mass is always (0,0,0). It can vary for [WedgePart](/docs/reference/engine/classes/WedgePart) or [MeshPart](/docs/reference/engine/classes/MeshPart) however. ### CollisionGroup [string](/docs/luau/strings) Not Replicated [Read Parallel](/docs/scripting/multithreading) The [CollisionGroup](/docs/reference/engine/classes/BasePart#CollisionGroup) property describes the name of the part's collision group (maximum of 100 characters). Parts start off in the default group whose name is "Default". This value cannot be empty. #### Code Samples This example demonstrates one basic use of collision groups. It assigns BallPart to "CollisionGroupBall" and DoorPart to "CollisionGroupDoor", then makes the two groups non-collidable using [PhysicsService:CollisionGroupSetCollidable()](/docs/reference/engine/classes/PhysicsService#CollisionGroupSetCollidable). 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 workspace.BallPart.CollisionGroup = collisionGroupBall workspace.DoorPart.CollisionGroup = collisionGroupDoor -- Set groups as non-collidable and check the result PhysicsService:CollisionGroupSetCollidable(collisionGroupBall, collisionGroupDoor, false) print(PhysicsService:CollisionGroupsAreCollidable(collisionGroupBall, collisionGroupDoor)) --> false ### CollisionGroupId [number](/docs/luau/numbers) Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) The [BasePart.CollisionGroupId](/docs/reference/engine/classes/BasePart#CollisionGroupId) property describes the ID number of the part's collision group. Parts start off in the "Default" group whose ID is 0. If a part is unregistered, the value becomes -1. This value cannot be less than -1 and it cannot exceed [PhysicsService:GetMaxCollisionGroups()](/docs/reference/engine/classes/PhysicsService#GetMaxCollisionGroups). Invalid IDs are clamped. Although this property can be directly changed, it's recommended that you specify the collision group by setting [BasePart.CollisionGroup](/docs/reference/engine/classes/BasePart#CollisionGroup) to the collision group's name. ### Color [Color3](/docs/reference/engine/datatypes/Color3) Not Replicated [Read Parallel](/docs/scripting/multithreading) The Color property determines the color of a part. If the part has a [BasePart.Material](/docs/reference/engine/classes/BasePart#Material), this also determines the color used when rendering the material texture. If this property is set, [BasePart.BrickColor](/docs/reference/engine/classes/BasePart#BrickColor) will use the closest BrickColor to the Color3 value. Other visual properties of a part are determined by [BasePart.Transparency](/docs/reference/engine/classes/BasePart#Transparency) and [BasePart.Reflectance](/docs/reference/engine/classes/BasePart#Reflectance). #### Code Samples This code sample colors a player's entire character based on how much health they have. It generates a color based on their max health, then sets the color properties of objects within their character, removing any extra objects. 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 [PhysicalProperties](/docs/reference/engine/datatypes/PhysicalProperties) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) CurrentPhysicalProperties indicates the current physical properties of the part. You can set custom values for the physical properties per part, [custom material](https://prod.docsiteassets.roblox.com/parts/materials.md), and material override. The Engine prioritizes more granular definitions when determining the effective physical properties of a part. The values in the following list are in order from highest to lowest priority: * Custom physical properties of the part * Custom physical properties of the part's custom material * Custom physical properties of the material override of the part's material * Default physical properties of the part's material ### CustomPhysicalProperties [PhysicalProperties](/docs/reference/engine/datatypes/PhysicalProperties) [Read Parallel](/docs/scripting/multithreading) CustomPhysicalProperties lets you customize various physical aspects of a [Part](/docs/reference/engine/classes/BasePart), such as its density, friction, and elasticity. If enabled, this property let's you configure these physical properties. If disabled, these physical properties are determined by the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) of the part. The page for [Material](/docs/reference/engine/enums/Material) contains list of the various part materials. #### Code Samples This code sample demonstrates how to set the CustomPhysicalProperties property of a part. 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 [number](/docs/luau/numbers) Hidden Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This is only one of multiple physics-related properties. It has been deprecated in favor of [BasePart.CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties), which combines these properties into one. The Elasticity of a part is now determined by either its [Material](/docs/reference/engine/enums/Material) or its CustomPhysicalProperties. ### EnableFluidForces [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) When true, and when [Workspace.FluidForces](/docs/reference/engine/classes/Workspace#FluidForces) is enabled, causes the physics engine to compute aerodynamic forces on this [BasePart](/docs/reference/engine/classes/BasePart). ### ExtentsCFrame [CFrame](/docs/reference/engine/datatypes/CFrame) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The [CFrame](/docs/reference/engine/datatypes/CFrame) of the physical extents of the [BasePart](/docs/reference/engine/classes/BasePart), representing its physical center. ### ExtentsSize [Vector3](/docs/reference/engine/datatypes/Vector3) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The actual physical size of the [BasePart](/docs/reference/engine/classes/BasePart) as regarded by the physics engine, for example in [collision detection](https://prod.docsiteassets.roblox.com/workspace/collisions.md). ### Friction [number](/docs/luau/numbers) Hidden Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This is only one of multiple physics-related properties. It has been deprecated in favor of [BasePart.CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties), which combines these properties into one. Used to control the Friction of the part, but now it no longer does anything. The Friction of a part is now determined by either its [Material](/docs/reference/engine/classes/BasePart#Material) or its [CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties). ### FrontParamA [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The FrontParamA property is relevant when a part's [BasePart.FrontSurface](/docs/reference/engine/classes/BasePart#FrontSurface) is set to Motor or SteppingMotor and [BasePart.FrontSurfaceInput](/docs/reference/engine/classes/BasePart#FrontSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The FrontParamB property is relevant when a part's [BasePart.FrontSurface](/docs/reference/engine/classes/BasePart#FrontSurface) is set to Motor or SteppingMotor and [BasePart.FrontSurfaceInput](/docs/reference/engine/classes/BasePart#FrontSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The FrontSurface property determines the type of surface used for the -Z direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.FrontSurfaceInput](/docs/reference/engine/classes/BasePart#FrontSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes including Hinge, Motor, and SteppingMotor render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### FrontSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The FrontSurfaceInput property determines the kind of input provided to a part's [BasePart.FrontSurface](/docs/reference/engine/classes/BasePart#FrontSurface). This is only relevant for Motor or SteppingMotor SurfaceTypes. This property determines how [BasePart.FrontParamA](/docs/reference/engine/classes/BasePart#FrontParamA) and [BasePart.FrontParamB](/docs/reference/engine/classes/BasePart#FrontParamB) are used. For brevity, these properties will be referred to as ParamA and ParamB, respectively. * By default, this is set to NoInput. This stops the motor altogether. * For Constant, the motor rotates at a constant velocity equal to ParamB. * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The LeftParamA property is relevant when a part's [BasePart.LeftSurface](/docs/reference/engine/classes/BasePart#LeftSurface) is set to Motor or SteppingMotor and [BasePart.LeftSurfaceInput](/docs/reference/engine/classes/BasePart#LeftSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The LeftParamB property is relevant when a part's [BasePart.LeftSurface](/docs/reference/engine/classes/BasePart#LeftSurface) is set to Motor or SteppingMotor and [BasePart.LeftSurfaceInput](/docs/reference/engine/classes/BasePart#LeftSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The LeftSurface property determines the type of surface used for the -X direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.LeftSurfaceInput](/docs/reference/engine/classes/BasePart#LeftSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes including Hinge, Motor, and SteppingMotor render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### LeftSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The LeftSurfaceInput property determines the kind of input provided to a part's [BasePart.LeftSurface](/docs/reference/engine/classes/BasePart#LeftSurface). This is only relevant for Motor or SteppingMotor SurfaceTypes. This property determines how [BasePart.LeftParamA](/docs/reference/engine/classes/BasePart#LeftParamA) and [BasePart.LeftParamB](/docs/reference/engine/classes/BasePart#LeftParamB) are used. For brevity, these properties will be referred to as ParamA and ParamB, respectively. * By default, this is set to NoInput. This stops the motor altogether. * For Constant, the motor rotates at a constant velocity equal to ParamB. * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden Not Replicated [Read Parallel](/docs/scripting/multithreading) The [LocalTransparencyModifier](/docs/reference/engine/classes/BasePart#LocalTransparencyModifier) property is a multiplier to [BasePart.Transparency](/docs/reference/engine/classes/BasePart#Transparency) that is only visible to the local client. It does not replicate from client to server and is useful for when a part should not render for a specific client, such as how the player does not see their character's body parts when they zoom into first person mode. This property modifies the local part's transparency through the following formula, with resulting values clamped between 0 and 1. * * * clientTransparency = 1 - ((1 - part.Transparency) * (1 - part.LocalTransparencyModifier)) Transparency LocalTransparencyModifier Server-Side Transparency Client-Side Transparency 0.5 0 0.5 0.5 0.5 0.25 0.5 0.625 0.5 0.5 0.5 0.75 0.5 0.75 0.5 0.875 0.5 1 0.5 1 ### Locked [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) The Locked property determines whether a [part](/docs/reference/engine/classes/BasePart) (or a [model](/docs/reference/engine/classes/Model) it is contained within) may be selected in Roblox Studio by clicking on it. This property is most often enabled on parts within environment models that aren't being edited at the moment. Roblox Studio has a Lock/Unlock All tool that can toggle the Locked state of every part descendant in a model at once. #### Code Samples This code sample uses the concept of recursion to unlock all parts that are a descendant of a model. 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 [number](/docs/luau/numbers) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) Mass is a read-only property that describes the product of a part's volume and density. It is returned by the [GetMass](/docs/reference/engine/classes/BasePart#GetMass) function. * The volume of a part is determined by its [Size](/docs/reference/engine/classes/BasePart#Size) and its [Shape](/docs/reference/engine/classes/Part#Shape), which varies depending on the kind of BasePart used, such as [WedgePart](/docs/reference/engine/classes/WedgePart). * The density of a part is determined by its [Material](/docs/reference/engine/classes/BasePart#Material) or [CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties), if specified. ### Massless [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) If this property is enabled, the [BasePart](/docs/reference/engine/classes/BasePart) will not contribute to the total mass or inertia of its assembly as long as it is welded to another part that has mass. If the part is its own root part according to [AssemblyRootPart](/docs/reference/engine/classes/BasePart#AssemblyRootPart), this will be ignored for that part, and it will still contribute mass and inertia to its assembly like a normal part. Parts that are massless should never become an assembly root part unless all other parts in the assembly are also massless. This might be useful for things like optional accessories on vehicles that you don't want to affect the handling of the car or a massless render mesh welded to a simpler collision mesh. See also [Understanding Assemblies](https://prod.docsiteassets.roblox.com/physics/assemblies.md), an article documenting what root parts are and how to use them. ### Material [Material](/docs/reference/engine/enums/Material) [Read Parallel](/docs/scripting/multithreading) The Material property allows a builder to set a part's texture and default physical properties (in the case that [BasePart.CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties) is unset). The default Plastic material has a very light texture, and the SmoothPlastic material has no texture at all. Some material textures like DiamondPlate and Granite have very visible textures. Each material's texture reflects sunlight differently, especially Foil. Setting this property then enabling [BasePart.CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties) will use the default physical properties of a material. For instance, DiamondPlate is a very dense material while Wood is very light. A part's density determines whether it will float in terrain water. The Glass material changes rendering behavior on moderate graphics settings. It applies a bit of reflectiveness (similar to [BasePart.Reflectance](/docs/reference/engine/classes/BasePart#Reflectance)) and perspective distortion. The effect is especially pronounced on sphere-shaped parts (set [BasePart.Shape](/docs/reference/engine/classes/BasePart#Shape) to Ball). Semitransparent objects and Glass parts behind Glass are not visible. #### Code Samples This code sample will allow a part to be clicked to toggle its anchored property. When toggled, the visual appearance of the part is updated (red means anchored, yellow means free). 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) ### MaterialVariant [string](/docs/luau/strings) Not Replicated [Read Parallel](/docs/scripting/multithreading) The system searches the [MaterialVariant](/docs/reference/engine/classes/MaterialVariant) instance with specified MaterialVariant name and [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) type. If it successfully finds a matching MaterialVariant instance, it uses this MaterialVariant instance to replace the default material. Default material can be the built-in material or an override MaterialVariant specified in [MaterialService](/docs/reference/engine/classes/MaterialService). ### Orientation [Vector3](/docs/reference/engine/datatypes/Vector3) Hidden Not Replicated [Read Parallel](/docs/scripting/multithreading) The Orientation property describes the part's rotation in degrees around the X, Y and Z axes using a Vector3. The rotations are applied in Y → X → Z order. This differs from proper [Euler angles](https://en.wikipedia.org/wiki/Euler_angles) and is instead [Tait-Bryan angles](https://en.wikipedia.org/wiki/Euler_angles#Tait-Bryan_angles), which describe yaw, pitch and roll. It is also worth noting how this property differs from the [CFrame.Angles()](/docs/reference/engine/datatypes/CFrame#Angles) constructor, which applies rotations in a different order (Z → Y → X). For better control over the rotation of a part, it is recommended that [BasePart.CFrame](/docs/reference/engine/classes/BasePart#CFrame) is set instead. When setting this property any [Welds](/docs/reference/engine/classes/Weld) or [Motor6Ds](/docs/reference/engine/classes/Motor6D) connected to this part will have the matching [C0](/docs/reference/engine/classes/JointInstance#C0) or [C1](/docs/reference/engine/classes/JointInstance#C1) property updated and to allow the part to move relative to any other parts it is joined to. WeldConstraints will also be temporarily disabled and re-enabled during the move. #### Code Samples This code sample rotates a part continually on the Y axis. 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 [CFrame](/docs/reference/engine/datatypes/CFrame) [Read Parallel](/docs/scripting/multithreading) This property specifies the offset of the part's pivot from its [CFrame](/docs/reference/engine/datatypes/CFrame), that is part:GetPivot() is the same as part.CFrame \* part.PivotOffset. This is convenient for setting the pivot to a location in local space, but setting a part's pivot to a location in world space can be done as follows: * * * local part = workspace.BluePart local desiredPivotCFrameInWorldSpace = CFrame.new(0, 10, 0) part.PivotOffset = part.CFrame:ToObjectSpace(desiredPivotCFrameInWorldSpace) #### Code Samples This code sample shows a custom function for resetting the pivot of a model back to the center of that model's bounding box. 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) This code sample creates a clock at the origin with a minute, second, and hour hand, and makes it tick, displaying the local time. 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 [Vector3](/docs/reference/engine/datatypes/Vector3) Hidden Not Replicated [Read Parallel](/docs/scripting/multithreading) The Position property describes the coordinates of a [part](/docs/reference/engine/classes/BasePart) using a [Vector3](/docs/reference/engine/datatypes/Vector3). It reflects the position of the part's [BasePart.CFrame](/docs/reference/engine/classes/BasePart#CFrame), however it can also be set. When setting this property any [Welds](/docs/reference/engine/classes/Weld) or [Motor6Ds](/docs/reference/engine/classes/Motor6D) connected to this part will have the matching [C0](/docs/reference/engine/classes/JointInstance#C0) or [C1](/docs/reference/engine/classes/JointInstance#C1) property updated and to allow the part to move relative to any other parts it is joined to. WeldConstraints will also be temporarily disabled and re-enabled during the move. ### ReceiveAge [number](/docs/luau/numbers) Hidden Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) This returns the time in seconds since the part's physics got last updated on the local client (or the server). Returns 0 when the part has no physics (Anchored) ### Reflectance [number](/docs/luau/numbers) [Read Parallel](/docs/scripting/multithreading) The Reflectance property determines how much a [part](/docs/reference/engine/classes/BasePart) reflects the skybox. A value of 0 indicates the part is not reflective at all, and a value of 1 indicates the part should fully reflect. Reflectance is not affected by [BasePart.Transparency](/docs/reference/engine/classes/BasePart#Transparency), unless the part is fully transparent, in which case reflectance will not render at all. Reflectance may or may not be ignored depending on the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) of the part. #### Code Samples This code sample causes a part to blink its Reflectance and a PointLight every time it is touched. It uses a pattern that prevents multiple concurrent function calls from fighting with each other. Touch Blink * * * 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 [number](/docs/luau/numbers) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The ResizeIncrement property is a read-only property that describes the smallest change in size allowable by the [BasePart:Resize()](/docs/reference/engine/classes/BasePart#Resize) method. It differs between implementations of the [BasePart](/docs/reference/engine/classes/BasePart) abstract class. For instance, [Part](/docs/reference/engine/classes/Part) has this set to 1 and [TrussPart](/docs/reference/engine/classes/TrussPart) has this set to 2 (since individual truss sections are 2x2x2 in size). #### Code Samples This code sample creates a Handles object and shows how to set the Faces property of the object. It also references ResizeableFaces of a part. Try placing this script in multiple kinds of parts to see how ResizeableFaces varies. 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 ### ResizeableFaces [Faces](/docs/reference/engine/datatypes/Faces) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) The ResizeableFaces property (with an e, not ResizableFaces) describes using a Faces object the different faces on which a part may be resized. For most implementations of [BasePart](/docs/reference/engine/classes/BasePart), such as [Part](/docs/reference/engine/classes/Part) and [WedgePart](/docs/reference/engine/classes/WedgePart), this property includes all faces. However, [TrussPart](/docs/reference/engine/classes/TrussPart) will set its ResizeableFaces set to only two faces since those kinds of parts must have two [BasePart.Size](/docs/reference/engine/classes/BasePart#Size) dimensions of length 2. This property is most commonly used with tools used for building and manipulating parts and has little use outside of that context. The [Handles](/docs/reference/engine/classes/Handles) class, which has the [Handles.Faces](/docs/reference/engine/classes/Handles#Faces) property, can be used in conjunction with this property to display only the handles on faces that can be resized on a part. #### Code Samples This code sample creates a Handles object and shows how to set the Faces property of the object. It also references ResizeableFaces of a part. Try placing this script in multiple kinds of parts to see how ResizeableFaces varies. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The RightParamA property is relevant when a part's [BasePart.RightSurface](/docs/reference/engine/classes/BasePart#RightSurface) is set to Motor or SteppingMotor and [BasePart.RightSurfaceInput](/docs/reference/engine/classes/BasePart#RightSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The RightParamB property is relevant when a part's [BasePart.RightSurface](/docs/reference/engine/classes/BasePart#RightSurface) is set to Motor or SteppingMotor and [BasePart.RightSurfaceInput](/docs/reference/engine/classes/BasePart#RightSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The RightSurface property determines the type of surface used for the +X direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.RightSurfaceInput](/docs/reference/engine/classes/BasePart#RightSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes including Hinge, Motor, and SteppingMotor will render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### RightSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The RightSurfaceInput property determines the kind of input provided to a * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) [Read Parallel](/docs/scripting/multithreading) This property is an integer between -127 and 127 that takes precedence over all other rules for root part sort. When considering multiple parts that are not [Anchored](/docs/reference/engine/classes/BasePart#Anchored) and which share the same [Massless](/docs/reference/engine/classes/BasePart#Massless) value, a part with a higher RootPriority will take priority over those with lower RootPriority. You can use this property to control which part of an assembly is the root part and keep the root part stable if size changes. See also [Understanding Assemblies](https://prod.docsiteassets.roblox.com/physics/assemblies.md), an article documenting what root parts are and how to use them. ### RotVelocity [Vector3](/docs/reference/engine/datatypes/Vector3) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This property is deprecated. Use AssemblyAngularVelocity instead. The RotVelocity of a [part](/docs/reference/engine/classes/BasePart) describes how its [BasePart.Orientation](/docs/reference/engine/classes/BasePart#Orientation) is presently changing. In other words, this property describes how the fast part is rotating. The part only rotates if it is not anchored. The unit of this property is radians per second. Using this in conjunction with [AlignOrientation](/docs/reference/engine/classes/AlignOrientation) allows for aligned parts to have matching RotVelocity and Orientation values. #### Code Samples The script below creates a new BasePart|part and sets its [Part.RotVelocity](/docs/reference/engine/classes/Part#RotVelocity) to Vector3.new(0, 10, 0) every [RunService.RenderStepped](/docs/reference/engine/classes/RunService#RenderStepped) so that the part rotates in a circular motion. 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 [Vector3](/docs/reference/engine/datatypes/Vector3) Not Replicated [Read Parallel](/docs/scripting/multithreading) The rotation of the part in degrees for the three axes. When setting this property any [Welds](/docs/reference/engine/classes/Weld) or [Motor6Ds](/docs/reference/engine/classes/Motor6D) connected to this part will have the matching [C0](/docs/reference/engine/classes/JointInstance#C0) or [C1](/docs/reference/engine/classes/JointInstance#C1) property updated and to allow the part to move relative to any other parts it is joined to. WeldConstraints will also be temporarily disabled and re-enabled during the move. ### Size [Vector3](/docs/reference/engine/datatypes/Vector3) Not Replicated [Read Parallel](/docs/scripting/multithreading) A part's [Size](/docs/reference/engine/classes/BasePart#Size) property determines its visual dimensions, while [ExtentsSize](/docs/reference/engine/classes/BasePart#ExtentsSize) represents the actual size used by the physics engine, for example in [collision detection](https://prod.docsiteassets.roblox.com/workspace/collisions.md). The individual dimensions (length, width, height) can be as low as 0.001 and as high as 2048. Size dimensions below 0.05 will be visually represented as if the part's dimensions are 0.05. The size of the part determines its mass which is given by [BasePart:GetMass()](/docs/reference/engine/classes/BasePart#GetMass). A part's [Size](/docs/reference/engine/classes/BasePart#Size) is used by a variety of other objects: * [ParticleEmitter](/docs/reference/engine/classes/ParticleEmitter) to determine the area from which particles are spawned. * [BlockMesh](/docs/reference/engine/classes/BlockMesh) to partially determine the rendered rectangular prism. * [SpecialMesh](/docs/reference/engine/classes/SpecialMesh) for certain [MeshTypes](/docs/reference/engine/classes/SpecialMesh#MeshType), to determine the size of the rendered mesh. * [SurfaceLight](/docs/reference/engine/classes/SurfaceLight) to determine the space to illuminate. #### Code Samples This code sample constructs a pyramid by stacking parts that get progressively smaller. It also colors the parts so they blend between a start color and end color. 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 [number](/docs/luau/numbers) Read Only Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This item is deprecated. See [BasePart.CustomPhysicalProperties](/docs/reference/engine/classes/BasePart#CustomPhysicalProperties) to see how to configure the physical properties of BaseParts. Do not use it for new work. The ratio of the part's density to the density of water determined by the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material). Effects the part's behavior when in a water terrain cell. Essentially, SpecificGravity refers to how many times more dense a part is than water. Material SpecificGravity Plastic 0.7 Wood 0.35 Slate 2.7 Concrete 2.4 CorrodedMetal 7.85 DiamondMetal 7.85 Foil 7.6 Grass 0.9 Ice 0.91 Marble 2.56 Granite 2.7 Brick 1.92 Pebble 2.4 Sand 1.6 Fabric 0.7 SmoothPlastic 0.7 Metal 7.85 WoodPlanks 0.35 Cobblestone 2.7 ### TopParamA [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The TopParamA property is relevant when a part's [BasePart.TopSurface](/docs/reference/engine/classes/BasePart#TopSurface) is set to Motor or SteppingMotor and [BasePart.TopSurfaceInput](/docs/reference/engine/classes/BasePart#TopSurfaceInput) is set to Sin. It determines the amplitude of the motor's rotational velocity, using the following formula: MotorVelocity = ParamA \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The TopParamB property is relevant when a part's [BasePart.TopSurface](/docs/reference/engine/classes/BasePart#TopSurface) is set to Motor or SteppingMotor and [BasePart.TopSurfaceInput](/docs/reference/engine/classes/BasePart#TopSurfaceInput) is set to Constant or Sin. For Constant, it determines the constant rotational velocity of the motor. For Sin, it determines the frequency of the motor's rotational velocity, using the following formula: MotorVelocity = ParamB \* math.sin(workspace.DistributedGameTime \* ParamB) In no other cases is this property used. #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 ### TopSurface [SurfaceType](/docs/reference/engine/enums/SurfaceType) [Read Parallel](/docs/scripting/multithreading) The TopSurface property determines the type of surface used for the +Y direction of a part. When two parts' faces are placed next to each other, they may create a joint between them. If set to Motor, the [BasePart.TopSurfaceInput](/docs/reference/engine/classes/BasePart#TopSurfaceInput) determines how a motor joint should behave. Most SurfaceTypes render a texture on the part face if the [BasePart.Material](/docs/reference/engine/classes/BasePart#Material) is set to Plastic. Some SurfaceTypes - Hinge, Motor and SteppingMotor - will render a 3D adornment instead. If this property is selected in the Properties window, it will be highlighted in the game world similar to that of a [SurfaceSelection](/docs/reference/engine/classes/SurfaceSelection). #### Code Samples This code sample shows what each SurfaceType looks like on a part. In addition, it creates a BillboardGui label on the part with a TextLabel that reflects the name of the current SurfaceType. Show All SurfaceTypes * * * 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 ### TopSurfaceInput [InputType](/docs/reference/engine/enums/InputType) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) The TopSurfaceInput property determines the kind of input provided to a part's [BasePart.TopSurface](/docs/reference/engine/classes/BasePart#TopSurface). This is only relevant for Motor or SteppingMotor SurfaceTypes. This property determines how [BasePart.TopParamA](/docs/reference/engine/classes/BasePart#TopParamA) and [BasePart.TopParamB](/docs/reference/engine/classes/BasePart#TopParamB) are used. For brevity, these properties will be referred to as ParamA and ParamB, respectively. * By default, this is set to NoInput. This stops the motor altogether, * For Constant, the motor rotates at a constant velocity equal to ParamB. * For Sin, the motor rotates at a velocity equal to ParamA \* math.sin(workspace.DistributedGameTime \* ParamB). See [Workspace.DistributedGameTime](/docs/reference/engine/classes/Workspace#DistributedGameTime). #### Code Samples This code sample demonstrates how surface properties can be set using only a NormalId (Top, Front, etc). It switches a motor's -SurfaceInput from NoInput, Constant and Sin to show how each work using -ParamA and -ParamB properties. 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 [number](/docs/luau/numbers) [Read Parallel](/docs/scripting/multithreading) The Transparency property controls the visibility of a part on a scale of 0 to 1, where 0 is completely visible (opaque), and a value of 1 is completely invisible (not rendered at all). [BasePart.Reflectance](/docs/reference/engine/classes/BasePart#Reflectance) can reduce the overall transparency of a brick if set to a value close to 1. While fully transparent parts are not rendered at all, partially transparent objects have some significant rendering costs. Having many translucent parts may slow down the game's performance. When transparent parts overlap, render order can act unpredictable - try to keep semi-transparent parts from overlapping to avoid this. The [BasePart.LocalTransparencyModifier](/docs/reference/engine/classes/BasePart#LocalTransparencyModifier) is a multiplier to Transparency that is only visible to the local client. #### Code Samples This code sample shows how a part can fade away when touched by a Humanoid then reappear a moment after to create a passable door. 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() This code sample gives the local client X-ray vision using LocalTransparencyModifier. It allows the player to see through all parts in the Workspace, which are found using recursion. X-Ray Vision * * * 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) ### Velocity [Vector3](/docs/reference/engine/datatypes/Vector3) Hidden DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This property is deprecated. Use AssemblyLinearVelocity instead. The Velocity of a part describes how its [BasePart.Position](/docs/reference/engine/classes/BasePart#Position) is presently changing. The unit of this property is studs per second. For reference, the default Roblox character moves at 16 studs per second via [Humanoid.WalkSpeed](/docs/reference/engine/classes/Humanoid#WalkSpeed). The acceleration due to gravity is found in [Workspace.Gravity](/docs/reference/engine/classes/Workspace#Gravity) (by default, -196.2 studs per second per second). Setting the Velocity of an part that is [BasePart.Anchored](/docs/reference/engine/classes/BasePart#Anchored) will cause it to act like a conveyor belt. Any object that touches the part will begin to move in accordance with the Velocity. Some [BodyMover](/docs/reference/engine/classes/BodyMover) objects will apply forces and thus change the Velocity of a part over time. The simplest of these is a [BodyForce](/docs/reference/engine/classes/BodyForce) which can be used to counteract the acceleration due to gravity on a single part (set the +Y axis of the [BodyForce.Force](/docs/reference/engine/classes/BodyForce#Force) to the product of the mass ([BasePart:GetMass()](/docs/reference/engine/classes/BasePart#GetMass)) and the gravity constant). #### Code Samples This code sample fires a part from one position toward another. It calculates the velocity needed to reach the destination in time, and applies an anti-gravity effect using a BodyForce. In addition, it adds a Trail to better visualize the path of the projectile as it arcs through the air. 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 [BrickColor](/docs/reference/engine/datatypes/BrickColor) Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This deprecated property is an old Camel Case variant of the Pascal Case [BasePart.BrickColor](/docs/reference/engine/classes/BasePart#BrickColor), which should be used instead. Properties inherited from PVInstance ### Origin [CFrame](/docs/reference/engine/datatypes/CFrame) Not Replicated Not Scriptable [Read Parallel](/docs/scripting/multithreading) ### Pivot Offset [CFrame](/docs/reference/engine/datatypes/CFrame) Not Replicated Not Scriptable [Read Parallel](/docs/scripting/multithreading) Properties inherited from Instance ### Archivable [boolean](/docs/luau/booleans) [Read Parallel](/docs/scripting/multithreading) This property determines whether an [object](/docs/reference/engine/classes/Instance) should be included when the game is published or saved, or when [Instance:Clone()](/docs/reference/engine/classes/Instance#Clone) is called on one of the object's ancestors. Calling Clone directly on an object will return nil if the cloned object is not archivable. Copying an object in Studio (using the 'Duplicate' or 'Copy' options) will ignore the Archivable property and set Archivable to true for the copy. * * * local part = Instance.new("Part") print(part:Clone()) --> Part part.Archivable = false print(part:Clone()) --> nil ### ClassName [string](/docs/luau/strings) Read Only Not Replicated [Read Parallel](/docs/scripting/multithreading) A read-only string representing the class this [Instance](/docs/reference/engine/classes/Instance) belongs to. This property can be used with various other functions of Instance that are used to identify objects by type, such as [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) or [Instance:FindFirstChildOfClass()](/docs/reference/engine/classes/Instance#FindFirstChildOfClass). Note this property is read only and cannot be altered by scripts. Developers wishing to change an [Instance](/docs/reference/engine/classes/Instance)'s class will instead have to create a new [Instance](/docs/reference/engine/classes/Instance). Unlike [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA), ClassName can be used to check if an object belongs to a specific class ignoring class inheritance. For example: * * * for _, child in ipairs(game.Workspace:GetChildren()) do if child.ClassName == "Part" then print("Found a Part") -- will find Parts in model, but NOT TrussParts, WedgeParts, etc end end ### Name [string](/docs/luau/strings) [Read Parallel](/docs/scripting/multithreading) A non-unique identifier of the [Instance](/docs/reference/engine/classes/Instance). This property is an identifier that describes an object. Names are not necessarily unique identifiers however; multiple children of an object may share the same name. Names are used to keep the object hierarchy organized, along with allowing scripts to access specific objects. The name of an object is often used to access the object through the data model hierarchy using the following methods: * * * local baseplate = workspace.Baseplate local baseplate = workspace["Baseplate"] local baseplate = workspace:FindFirstChild("BasePlate") In order to make an object accessible using the dot operator, an object's Name must follow a certain syntax. The objects name must start with an underscore or letter. The rest of the name can only contain letters, numbers, or underscores (no other special characters). If an objects name does not follow this syntax it will not be accessible using the dot operator and Lua will not interpret its name as an identifier. If more than one object with the same name are siblings then any attempt to index an object by that name will return the only one of the objects found similar to [Instance:FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild), but not always the desired object. If a specific object needs to be accessed through code, it is recommended to give it a unique name, or guarantee that none of its siblings share the same name as it. Note, a full name showing the instance's hierarchy can be obtained using [Instance:GetFullName()](/docs/reference/engine/classes/Instance#GetFullName). ### Parent [Instance](/docs/reference/engine/classes/Instance) Not Replicated [Read Parallel](/docs/scripting/multithreading) The Parent property determines the hierarchical parent of the [Instance](/docs/reference/engine/classes/Instance). The following terminology is commonly used when talking about how this property is set: * An object is a child (parented to) another object when its Parent is set to that object. * The descendants of an [Instance](/docs/reference/engine/classes/Instance) are the children of that object, plus the descendants of the children as well. * The ancestors of an [Instance](/docs/reference/engine/classes/Instance) are all the objects that the Instance is a descendant of. It is from this property that many other API members get their name, such as [GetChildren](/docs/reference/engine/classes/Instance#GetChildren) and [FindFirstChild](/docs/reference/engine/classes/Instance#FindFirstChild). The [Remove](/docs/reference/engine/classes/Instance#Remove) function sets this property to nil. Calling [Destroy](/docs/reference/engine/classes/Instance#Destroy) will set the Parent of an [Instance](/docs/reference/engine/classes/Instance) and all of its descendants to nil, and also lock the Parent property. An error is raised when setting the Parent of a destroyed object. This property is also used to manage whether an object exists in the game or needs removed. As long as an objects parent is in the [DataModel](/docs/reference/engine/classes/DataModel), is stored in a variable, or is referenced by another objects property, then the object remains in the game. Otherwise, the object will automatically be removed. The top level [DataModel](/docs/reference/engine/classes/DataModel) object (the one referred to as the game by scripts) has no parent, but always has a reference held to it by the game engine, and exists for the duration of a session. Newly created objects using [Instance.new()](/docs/reference/engine/datatypes/Instance#new) will not have a parent, and usually will not be visible or function until one is set. The most elementary creation of an object has two steps: creating the object, then setting its parent. * * * -- Create a part and parent it to the workspace local part = Instance.new("Part") part.Parent = workspace -- Instance new can also take Parent as a second parameter Instance.new("NumberValue", workspace) #### Object Replication An object created by server will not replicate to clients until it is parented to some object that is replicated. When creating an object then setting many properties, it's recommended to set Parent last. This ensures the object replicates once, instead of replicating many property changes. * * * local part = Instance.new("Part") -- Avoid using the second parameter here part.Anchored = true part.BrickColor = BrickColor.new("Really red") -- Potentially many other property changes could go here here... -- Always set parent last! part.Parent = workspace However, if you were parenting your parts to a [Model](/docs/reference/engine/classes/Model) whose parent hasn't been set yet, then setting the parent first would not matter as the model would not have replicated yet. ### RobloxLocked [boolean](/docs/luau/booleans) Hidden Plugin Security [Read Parallel](/docs/scripting/multithreading) This property used to protect objects in the [CoreGui](/docs/reference/engine/classes/CoreGui) service from being altered by users in an unauthorized manner. It has been deprecated and does not do anything. ### archivable [boolean](/docs/luau/booleans) Hidden Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This deprecated property is a variant of [Instance.Archivable](/docs/reference/engine/classes/Instance#Archivable) which should be used instead. ### className [string](/docs/luau/strings) Read Only Not Replicated DEPRECATED [Read Parallel](/docs/scripting/multithreading) DEPRECATED This deprecated property is a variant of [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) which should be used instead. Methods ------- Methods inherited from BasePart ### ApplyAngularImpulse void Applies an instant angular force impulse to this [part](/docs/reference/engine/classes/BasePart)'s assembly, causing the assembly to spin. The resulting angular velocity from the impulse relies on the assembly's [mass](/docs/reference/engine/classes/BasePart#AssemblyMass). So a higher impulse is required to move more massive assemblies. Impulses are useful for cases where you want a force applied instantly, such as an explosion or collision. If the part is owned by the server, this function must be called on a server [Script](/docs/reference/engine/classes/Script). If the part is owned by a client, this function can be called on a [LocalScript](/docs/reference/engine/classes/LocalScript) or server [Script](/docs/reference/engine/classes/Script). #### Parameters impulse: [Vector3](/docs/reference/engine/datatypes/Vector3) A force vector to be applied to the assembly as an impulse. #### Returns void ### ApplyImpulse void This function applies an instant force impulse to this [part](/docs/reference/engine/classes/BasePart)'s assembly. The force is applied at the assembly's [center of mass](/docs/reference/engine/classes/BasePart#AssemblyCenterOfMass), so the resulting movement will only be linear. The resulting velocity from the impulse relies on the assembly's [mass](/docs/reference/engine/classes/BasePart#AssemblyMass). So a higher impulse is required to move more massive assemblies. Impulses are useful for cases where you want a force applied instantly, such as an explosion or collision. If the part is owned by the server, this function must be called on a server [Script](/docs/reference/engine/classes/Script). If the part is owned by a client, this function can be called on a [LocalScript](/docs/reference/engine/classes/LocalScript) or server [Script](/docs/reference/engine/classes/Script). #### Parameters impulse: [Vector3](/docs/reference/engine/datatypes/Vector3) A force vector to be applied to the assembly as an impulse. #### Returns void ### ApplyImpulseAtPosition void This function applies an instant force impulse to this [part](/docs/reference/engine/classes/BasePart)'s assembly, at the specified position in world space. If the position is not at the assembly's [center of mass](/docs/reference/engine/classes/BasePart#AssemblyCenterOfMass), the impulse will cause a positional and rotational movement. The resulting velocity from the impulse relies on the assembly's [mass](/docs/reference/engine/classes/BasePart#AssemblyMass). So a higher impulse is required to move more massive assemblies. Impulses are useful for cases where developers want a force applied instantly, such as an explosion or collision. If the part is owned by the server, this function must be called on a server [Script](/docs/reference/engine/classes/Script). If the part is owned by a client, this function can be called on a [LocalScript](/docs/reference/engine/classes/LocalScript) or server [Script](/docs/reference/engine/classes/Script). #### Parameters impulse: [Vector3](/docs/reference/engine/datatypes/Vector3) A force vector to be applied to the assembly as an impulse. position: [Vector3](/docs/reference/engine/datatypes/Vector3) The position, in world space, to apply the impulse. #### Returns void ### BreakJoints void DEPRECATED Breaks any surface connection with any adjacent part, including [Weld](/docs/reference/engine/classes/Weld) and other [JointInstance](/docs/reference/engine/classes/JointInstance). #### Returns void ### CanCollideWith [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) Returns whether the parts can collide with each other or not. This function takes into account the collision groups of the two parts. This function will error if the specified part is not a BasePart. #### Parameters part: [BasePart](/docs/reference/engine/classes/BasePart) The specified part being checked for collidability. #### Returns [boolean](/docs/luau/booleans) Whether the parts can collide with each other. ### CanSetNetworkOwnership [Tuple](/docs/luau/tuples) The CanSetNetworkOwnership function checks whether you can set a [part](/docs/reference/engine/classes/BasePart)'s network ownership. The function's return value verifies whether or not you can call [BasePart:SetNetworkOwner()](/docs/reference/engine/classes/BasePart#SetNetworkOwner) or [BasePart:SetNetworkOwnershipAuto()](/docs/reference/engine/classes/BasePart#SetNetworkOwnershipAuto) without encountering an error. It returns true if you can modify/read the network ownership, or returns false and the reason you can't, as a string. #### Returns [Tuple](/docs/luau/tuples) Whether you can modify or read the network ownership and the reason. #### Code Samples This example checks whether or not the network ownership of the first BasePart named _Part_ in the Workspace can be set. 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 [Vector3](/docs/reference/engine/datatypes/Vector3) #### Parameters position: [Vector3](/docs/reference/engine/datatypes/Vector3) #### Returns [Vector3](/docs/reference/engine/datatypes/Vector3) ### GetConnectedParts [Objects](/docs/luau/tuples) [Write Parallel](/docs/scripting/multithreading) Returns a table of parts connected to the object by any kind of rigid joint. If recursive is true this function will return all of the parts in the assembly rigidly connected to the BasePart. #### Rigid Joints When a joint connects two parts together (Part0 → Part1), a joint is rigid if the physics of Part1 are completely locked down by Part0. This only applies to the following joint types: * [Weld](/docs/reference/engine/classes/Weld) * [Snap](/docs/reference/engine/classes/Snap) * [ManualWeld](/docs/reference/engine/classes/ManualWeld) * [Motor](/docs/reference/engine/classes/Motor) * [Motor6D](/docs/reference/engine/classes/Motor6D) * [WeldConstraint](/docs/reference/engine/classes/WeldConstraint) #### Parameters recursive: [boolean](/docs/luau/booleans) A table of parts connected to the object by any kind of [joint](/docs/reference/engine/classes/JointInstance). Default Value: false #### Returns [Objects](/docs/luau/tuples) ### GetJoints [Objects](/docs/luau/tuples) [Write Parallel](/docs/scripting/multithreading) Return all Joints or Constraints that is connected to this Part. #### Returns [Objects](/docs/luau/tuples) An array of all Joints or Constraints connected to the Part. ### GetMass [number](/docs/luau/numbers) [Write Parallel](/docs/scripting/multithreading) GetMass returns the value of the read-only [Mass](/docs/reference/engine/classes/BasePart#Mass) property. This function predates the Mass property. It remains supported for backward-compatibility; you should use the Mass property directly. #### Returns [number](/docs/luau/numbers) The part's mass. #### Code Samples This example creates a new part, myPart, in the game's Workspace, with dimensions 4x6x4 studs. The part is also anchored. Then, myMass is set to equal the mass of the new part. The mass of the part is printed at the end of the print statement: My part's mass is ... 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 [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the current player who is the network owner of this part, or nil in case of the server. #### Returns [Instance](/docs/reference/engine/classes/Instance) The current player who is the network owner of this part, or nil in case of the server. ### GetNetworkOwnershipAuto [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) Returns true if the game engine automatically decides the network owner for this part. #### Returns [boolean](/docs/luau/booleans) Whether the game engine automatically decides the network owner for this part. ### GetNoCollisionConstraints [Objects](/docs/luau/tuples) #### Returns [Objects](/docs/luau/tuples) ### GetRenderCFrame [CFrame](/docs/reference/engine/datatypes/CFrame) DEPRECATED DEPRECATED This item is been deprecated since interpolation is now applied to the [CFrame](/docs/reference/engine/datatypes/CFrame) directly. Do not use it for new work. This function used to be relevant when Roblox's lag-compensating interpolation of parts online was internal. The interpolation is now applied to the [CFrame](/docs/reference/engine/datatypes/CFrame) directly. #### Returns [CFrame](/docs/reference/engine/datatypes/CFrame) ### GetRootPart [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the base part of an assembly. When moving an assembly of parts using a [CFrame](/docs/reference/engine/datatypes/CFrame). it is important to move this base part (this will move all other parts connected to it accordingly). More information is available in the [Understanding Assemblies](https://prod.docsiteassets.roblox.com/physics/assemblies.md) article. This function predates the AssemblyRootPart property. It remains supported for backward-compatibility; you should use the AssemblyRootPart property directly. #### Returns [Instance](/docs/reference/engine/classes/Instance) The base part of an assembly (a collection of parts connected together). ### GetTouchingParts [Objects](/docs/luau/tuples) Returns a table of all parts that are physically interacting with this part. If the part itself has CanCollide set to false, then this function returns an empty table unless the part has a [TouchInterest](/docs/reference/engine/classes/TouchTransmitter) object parented to it (meaning something is connected to its Touched event). Parts that are adjacent but not intersecting are not considered touching. This function predates the [WorldRoot:GetPartsInPart()](/docs/reference/engine/classes/WorldRoot#GetPartsInPart) function, which provides more flexibility and avoids the special [TouchInterest](/docs/reference/engine/classes/TouchTransmitter) rules described above. Use [WorldRoot:GetPartsInPart()](/docs/reference/engine/classes/WorldRoot#GetPartsInPart) instead. #### Returns [Objects](/docs/luau/tuples) A table of all parts that intersect and can collide with this part. ### GetVelocityAtPosition [Vector3](/docs/reference/engine/datatypes/Vector3) [Write Parallel](/docs/scripting/multithreading) Returns the linear velocity of the part's assembly at the given position relative to this part. It can be used to identify the linear velocity of parts in an assembly other than the root part. If the assembly has no angular velocity, than the linear velocity will always be the same for every position. #### Parameters position: [Vector3](/docs/reference/engine/datatypes/Vector3) #### Returns [Vector3](/docs/reference/engine/datatypes/Vector3) ### IsGrounded [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) Returns true if the object is connected to a part that will hold it in place (eg an [BasePart.Anchored](/docs/reference/engine/classes/BasePart#Anchored) part), otherwise returns false. In an assembly that has an [BasePart.Anchored](/docs/reference/engine/classes/BasePart#Anchored) part, every other part is grounded. #### Returns [boolean](/docs/luau/booleans) Whether the object is connected to a part that will hold it in place. ### MakeJoints void DEPRECATED DEPRECATED SurfaceType based joining is deprecated, do not use MakeJoints for new projects. [WeldConstraints](/docs/reference/engine/classes/WeldConstraint) and [HingeConstraints](/docs/reference/engine/classes/HingeConstraint) should be used instead. Creates a joint on any side of the [Part](/docs/reference/engine/classes/BasePart) that has a [SurfaceType](/docs/reference/engine/enums/SurfaceType) that can make a joint it will create a joint with any adjacent parts. Joints will be created between the sides and any planar touching surfaces, depending on the sides' surfaces. * Smooth surfaces will not create joints * Glue surfaces will create a [Glue](/docs/reference/engine/classes/Glue) joint * Weld will create a [Weld](/docs/reference/engine/classes/Weld) joint with any surface except for Unjoinable * Studs, Inlet, or Universal will each create a [Snap](/docs/reference/engine/classes/Snap) joint with either of other the other two surfaces (e.g. Studs with Inlet and Universal) * Hinge and Motor surfaces create [Rotate](/docs/reference/engine/classes/Rotate) and [RotateV](/docs/reference/engine/classes/RotateV) joint instances Unlike [Model:MakeJoints()](/docs/reference/engine/classes/Model#MakeJoints), this function requires an array of parts as a parameter. This array is given as follows: * * * part:MakeJoints({part1, part2, part3}) Joints are broken if enough force is applied to them due to an [Explosion](/docs/reference/engine/classes/Explosion), unless a [ForceField](/docs/reference/engine/classes/ForceField) object is parented to the [BasePart](/docs/reference/engine/classes/BasePart) or ancestor [Model](/docs/reference/engine/classes/Model). For this reason, they are often used to make simple destructible buildings and other models. #### Returns void ### Resize [boolean](/docs/luau/booleans) Changes the size of an object just like using the Studio resize tool. #### Parameters normalId: [NormalId](/docs/reference/engine/enums/NormalId) The side to resize. deltaAmount: [number](/docs/luau/numbers) How much to grow/shrink on the specified side. #### Returns [boolean](/docs/luau/booleans) Whether the part is resized. ### SetNetworkOwner void Sets the given player as network owner for this and all connected parts. When playerInstance is nil, the server will be the owner instead of a player. #### Parameters playerInstance: [Player](/docs/reference/engine/classes/Player) The player being given network ownership of the part. Default Value: "nil" #### Returns void ### SetNetworkOwnershipAuto void Lets the game engine dynamically decide who will handle the part's physics (one of the clients or the server). #### Returns void ### breakJoints void DEPRECATED DEPRECATED This deprecated function is a variant of [BasePart:BreakJoints()](/docs/reference/engine/classes/BasePart#BreakJoints) which should be used instead. #### Returns void ### getMass [number](/docs/luau/numbers) DEPRECATED DEPRECATED This Camel Case property has been deprecated in favor of its Pascal Case variant, [BasePart:GetMass()](/docs/reference/engine/classes/BasePart#GetMass). #### Returns [number](/docs/luau/numbers) ### makeJoints void DEPRECATED DEPRECATED This deprecated function is a variant of [BasePart:MakeJoints()](/docs/reference/engine/classes/BasePart#MakeJoints) which should be used instead. #### Returns void ### resize [boolean](/docs/luau/booleans) DEPRECATED DEPRECATED This deprecated function is a variant of [BasePart:Resize()](/docs/reference/engine/classes/BasePart#Resize) which should be used instead. #### Parameters normalId: [NormalId](/docs/reference/engine/enums/NormalId) deltaAmount: [number](/docs/luau/numbers) #### Returns [boolean](/docs/luau/booleans) ### IntersectAsync [Instance](/docs/reference/engine/classes/Instance) Yields Creates a new [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) from the intersecting geometry of the part and the other parts in the given array. Only [Parts](/docs/reference/engine/classes/Part) are supported, not [Terrain](/docs/reference/engine/classes/Terrain) or [MeshParts](/docs/reference/engine/classes/MeshPart). Similar to [Clone()](/docs/reference/engine/classes/Instance#Clone), the returned object has no set [Parent](/docs/reference/engine/classes/Instance#Parent). The following properties from the calling part are applied to the resulting [IntersectOperation](/docs/reference/engine/classes/IntersectOperation): * [Color](/docs/reference/engine/classes/BasePart#Color), [Material](/docs/reference/engine/classes/BasePart#Material), [MaterialVariant](/docs/reference/engine/classes/BasePart#MaterialVariant), [Reflectance](/docs/reference/engine/classes/BasePart#Reflectance), [Transparency](/docs/reference/engine/classes/BasePart#Transparency) * [CanCollide](/docs/reference/engine/classes/BasePart#CanCollide) * [Anchored](/docs/reference/engine/classes/BasePart#Anchored), [Density](/docs/reference/engine/classes/BasePart#Density), [Elasticity](/docs/reference/engine/classes/BasePart#Elasticity), [ElasticityWeight](/docs/reference/engine/classes/BasePart#ElasticityWeight), [Friction](/docs/reference/engine/classes/BasePart#Friction), [FrictionWeight](/docs/reference/engine/classes/BasePart#FrictionWeight) In the following image comparison, [IntersectAsync()](/docs/reference/engine/classes/BasePart#IntersectAsync) is called on the purple block using a table containing the blue block. The resulting [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) resolves into a shape of the intersecting geometry of both parts. ![Two block parts overlapping](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Separate-Parts-To-Intersect.jpg) Separate parts ![Parts intersected into a new solid model](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Intersect-Result.jpg) Resulting [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) #### Notes * The original parts remain intact following a successful intersect operation. In most cases, you should [Destroy()](/docs/reference/engine/classes/Instance#Destroy) all of the original parts and parent the returned [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) to the same place as the calling [BasePart](/docs/reference/engine/classes/BasePart). * By default, the face colors of the resulting intersection are borrowed from the [Color](/docs/reference/engine/classes/BasePart#Color) property of the original parts. To change the entire intersection to a specific color, set its [UsePartColor](/docs/reference/engine/classes/PartOperation#UsePartColor) property to true. * If an intersect operation would result in a part with more than 20,000 triangles, it will be simplified to 20,000 triangles. #### Parameters parts: [Objects](/docs/luau/tuples) The objects taking part in the intersection. collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) The [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) value for the resulting [IntersectOperation](/docs/reference/engine/classes/IntersectOperation). Default Value: "Default" renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) The [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) value of the resulting [PartOperation](/docs/reference/engine/classes/PartOperation). Default Value: "Automatic" #### Returns [Instance](/docs/reference/engine/classes/Instance) Resulting [IntersectOperation](/docs/reference/engine/classes/IntersectOperation) with default name Intersect. ### SubtractAsync [Instance](/docs/reference/engine/classes/Instance) Yields Creates a new [UnionOperation](/docs/reference/engine/classes/UnionOperation) from the part, minus the geometry occupied by the parts in the given array. Only [Parts](/docs/reference/engine/classes/Part) are supported, not [Terrain](/docs/reference/engine/classes/Terrain) or [MeshParts](/docs/reference/engine/classes/MeshPart). Similar to [Clone()](/docs/reference/engine/classes/Instance#Clone), the returned object has no set [Parent](/docs/reference/engine/classes/Instance#Parent). Note that the resulting union cannot be empty due to subtractions. If the operation would result in completely empty geometry, it will fail. In the following image comparison, [SubtractAsync()](/docs/reference/engine/classes/BasePart#SubtractAsync) is called on the blue cylinder using a table containing the purple block. The resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) resolves into a shape that omits the block's geometry from that of the cylinder. ![Longer block overlapping a cylinder](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Separate-Parts-To-Subtract.jpg) Separate parts ![Block part subtracted from cylinder](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Negate-Result.jpg) Resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) #### Parameters parts: [Objects](/docs/luau/tuples) The objects taking part in the subtraction. collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) The [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) value for the resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation). Default Value: "Default" renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) The [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) value of the resulting [PartOperation](/docs/reference/engine/classes/PartOperation). Default Value: "Automatic" #### Returns [Instance](/docs/reference/engine/classes/Instance) Resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) with default name Union. #### Code Samples This example demonstrates how to subtract part(s) from another [BasePart](/docs/reference/engine/classes/BasePart) to form a negated [UnionOperation](/docs/reference/engine/classes/UnionOperation). BasePart:SubtractAsync() * * * local mainPart = workspace.BlueBlock local otherParts = {workspace.PurpleCylinder} -- 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 i = 1, #otherParts do otherParts[i]:Destroy() end ### UnionAsync [Instance](/docs/reference/engine/classes/Instance) Yields Creates a new [UnionOperation](/docs/reference/engine/classes/UnionOperation) from the part, plus the geometry occupied by the parts in the given array. Only [Parts](/docs/reference/engine/classes/Part) are supported, not [Terrain](/docs/reference/engine/classes/Terrain) or [MeshParts](/docs/reference/engine/classes/MeshPart). Similar to [Clone()](/docs/reference/engine/classes/Instance#Clone), the returned object has no set [Parent](/docs/reference/engine/classes/Instance#Parent). The following properties from the calling part are applied to the resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation): * [Color](/docs/reference/engine/classes/BasePart#Color), [Material](/docs/reference/engine/classes/BasePart#Material), [MaterialVariant](/docs/reference/engine/classes/BasePart#MaterialVariant), [Reflectance](/docs/reference/engine/classes/BasePart#Reflectance), [Transparency](/docs/reference/engine/classes/BasePart#Transparency) * [CanCollide](/docs/reference/engine/classes/BasePart#CanCollide) * [Anchored](/docs/reference/engine/classes/BasePart#Anchored), [Density](/docs/reference/engine/classes/BasePart#Density), [Elasticity](/docs/reference/engine/classes/BasePart#Elasticity), [ElasticityWeight](/docs/reference/engine/classes/BasePart#ElasticityWeight), [Friction](/docs/reference/engine/classes/BasePart#Friction), [FrictionWeight](/docs/reference/engine/classes/BasePart#FrictionWeight) In the following image comparison, [UnionAsync()](/docs/reference/engine/classes/BasePart#UnionAsync) is called on the blue block using a table containing the purple cylinder. The resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) resolves into a shape of the combined geometry of both parts. ![Block and cylinder parts overlapping](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Separate-Parts-To-Union.jpg) Separate parts ![Parts joined together into a single solid union](https://prod.docsiteassets.roblox.com/assets/modeling/solid-modeling/Union-Result.jpg) Resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) #### Notes * The original parts remain intact following a successful union operation. In most cases, you should [Destroy()](/docs/reference/engine/classes/Instance#Destroy) all of the original parts and parent the returned [UnionOperation](/docs/reference/engine/classes/UnionOperation) to the same place as the calling [BasePart](/docs/reference/engine/classes/BasePart). * By default, the resulting union respects the [Color](/docs/reference/engine/classes/BasePart#Color) property of each of its parts. To change the entire union to a specific color, set its [UsePartColor](/docs/reference/engine/classes/PartOperation#UsePartColor) property to true. * If an union operation would result in a part with more than 20,000 triangles, it will be simplified to 20,000 triangles. #### Parameters parts: [Objects](/docs/luau/tuples) The objects taking part in the union with the calling part. collisionfidelity: [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) The [CollisionFidelity](/docs/reference/engine/enums/CollisionFidelity) value for the resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation). Default Value: "Default" renderFidelity: [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) The [RenderFidelity](/docs/reference/engine/enums/RenderFidelity) value of the resulting [PartOperation](/docs/reference/engine/classes/PartOperation). Default Value: "Automatic" #### Returns [Instance](/docs/reference/engine/classes/Instance) Resulting [UnionOperation](/docs/reference/engine/classes/UnionOperation) with default name Union. #### Code Samples This example demonstrates how to combine the geometry of one [BasePart](/docs/reference/engine/classes/BasePart) with the geometry of other part(s) to form a [UnionOperation](/docs/reference/engine/classes/UnionOperation). BasePart:UnionAsync() * * * local mainPart = workspace.BlueBlock local otherParts = {workspace.PurpleCylinder} -- 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 i = 1, #otherParts do otherParts[i]:Destroy() end Methods inherited from PVInstance ### GetPivot [CFrame](/docs/reference/engine/datatypes/CFrame) [Write Parallel](/docs/scripting/multithreading) This function gets the pivot of a [PVInstance](/docs/reference/engine/classes/PVInstance). This is often used with [PVInstance:PivotTo()](/docs/reference/engine/classes/PVInstance#PivotTo) to move a model. [Models](/docs/reference/engine/classes/Model) and [BaseParts](/docs/reference/engine/classes/BasePart) are both [PVInstances](/docs/reference/engine/classes/PVInstance) ("Position Velocity Instances") and so both have this function. #### Returns [CFrame](/docs/reference/engine/datatypes/CFrame) #### Code Samples This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with [PVInstance:GetPivot()](/docs/reference/engine/classes/PVInstance#GetPivot) and calling PVInstance|PivotTo to move the character forwards. Simple Character Teleportation * * * -- This code should be placed in a LocalScript under StarterPlayerScripts local Players = game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local player = Players.LocalPlayer local function doTeleport(_actionName, inputState, _inputObject) local character = player.Character if character and character.Parent and inputState == Enum.UserInputState.Begin then -- Move the character 10 studs forwards in the direction they're facing local currentPivot = character:GetPivot() character:PivotTo(currentPivot * CFrame.new(0, 0, -10)) end end ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F) ### PivotTo void Transforms the [PVInstance](/docs/reference/engine/classes/PVInstance) along with all of its descendant [PVInstances](/docs/reference/engine/classes/PVInstance) such that the pivot is now located at the specified [CFrame](/docs/reference/engine/datatypes/CFrame). This is the primary function that should be used to move [Models](/docs/reference/engine/classes/Model) via scripting. [BaseParts](/docs/reference/engine/classes/BasePart) are moved in this way by having their [CFrame](/docs/reference/engine/datatypes/CFrame) transformed by the necessary offset. [Models](/docs/reference/engine/classes/Model) are moved in this way by having their [Model.WorldPivot](/docs/reference/engine/classes/Model#WorldPivot) transformed by the necessary offset. Note that for efficiency purposes, [Instance.Changed](/docs/reference/engine/classes/Instance#Changed) events are not fired for [Position](/docs/reference/engine/classes/BasePart#Position) and [Orientation](/docs/reference/engine/classes/BasePart#Orientation) of [BaseParts](/docs/reference/engine/classes/BasePart) moved in this way; they are only fired for [CFrame](/docs/reference/engine/datatypes/CFrame). When calling [PivotTo](/docs/reference/engine/classes/PVInstance#PivotTo) on [Models](/docs/reference/engine/classes/Model), the offsets of the descendant parts and models are cached, such that subsequent calls to [PivotTo](/docs/reference/engine/classes/PVInstance#PivotTo) on the same model do not accumulate floating point drift between the parts making up the model. [Models](/docs/reference/engine/classes/Model) and [BaseParts](/docs/reference/engine/classes/BasePart) are both [PVInstances](/docs/reference/engine/classes/PVInstance) ("Position Velocity Instances") and so both have this function. #### Parameters targetCFrame: [CFrame](/docs/reference/engine/datatypes/CFrame) The [CFrame](/docs/reference/engine/datatypes/CFrame) that the [PVInstance](/docs/reference/engine/classes/PVInstance) pivot should equal after moving it. #### Returns void #### Code Samples This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with [PVInstance:GetPivot()](/docs/reference/engine/classes/PVInstance#GetPivot) and calling PVInstance|PivotTo to move the character forwards. Simple Character Teleportation * * * -- This code should be placed in a LocalScript under StarterPlayerScripts local Players = game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local player = Players.LocalPlayer local function doTeleport(_actionName, inputState, _inputObject) local character = player.Character if character and character.Parent and inputState == Enum.UserInputState.Begin then -- Move the character 10 studs forwards in the direction they're facing local currentPivot = character:GetPivot() character:PivotTo(currentPivot * CFrame.new(0, 0, -10)) end end ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F) Methods inherited from Instance ### AddTag void This method applies a tag to the instance, with no effect if the tag is already applied. Successfully adding a tag will fire a signal created by [CollectionService:GetInstanceAddedSignal()](/docs/reference/engine/classes/CollectionService#GetInstanceAddedSignal) with the given tag. Note that when tagging an instance, it's common that some resources are used to give the tag its functionality, for example event connections or tables. To prevent memory leaks, it's a good idea to clean these up (disconnect, set to nil, etc.) when no longer needed for a tag. Do this when calling [Instance:RemoveTag()](/docs/reference/engine/classes/Instance#RemoveTag), calling [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy), or in a function connected to a signal returned by [CollectionService:GetInstanceRemovedSignal()](/docs/reference/engine/classes/CollectionService#GetInstanceRemovedSignal). #### Parameters tag: [string](/docs/luau/strings) #### Returns void ### ClearAllChildren void This function destroys all of an [Instance](/docs/reference/engine/classes/Instance)'s children. As [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy) also calls itself on the children of an object it is used on, this function will destroy all descendants. #### Alternatives to ClearAllChildren If the developer does not wish to destroy all descendants, they should use [Instance:GetChildren()](/docs/reference/engine/classes/Instance#GetChildren) or [Instance:GetDescendants()](/docs/reference/engine/classes/Instance#GetDescendants) to loop through an object and select what to destroy. For example, the following code sample will destroy all parts in an object. * * * for _, instance in pairs(object:GetDescendants()) do if instance:IsA("BasePart") then instance:Destroy() end end #### Returns void #### Code Samples This example creates a Part and adds a few sparkle objects to the part. Then it calls Part:ClearAllChildren() to remove all of the children. Instance:ClearAllChildren * * * local part = Instance.new("Part") -- add some sparkles for _ = 1, 3 do local sparkles = Instance.new("Sparkles") sparkles.Parent = part end print("Part has", #part:GetChildren(), "children") --> Part has 3 children part:ClearAllChildren() print("Part has", #part:GetChildren(), "children") --> Part has 0 children ### Clone [Instance](/docs/reference/engine/classes/Instance) Clone creates a copy of an object and all of its descendants, ignoring all objects that are not [Archivable](/docs/reference/engine/classes/Instance#Archivable). The copy of the root object is returned by this function and its [Parent](/docs/reference/engine/classes/Instance#Parent) is set to nil. If a reference property such as [ObjectValue.Value](/docs/reference/engine/classes/ObjectValue#Value) is set in a cloned object, the value of the copy's property depends on original's value: * If a reference property refers to an object that was also cloned, an _internal reference_, the copy will refer to the copy. * If a reference property refers to an object that was not cloned, an _external reference_, the same value is maintained in the copy. This function is typically used to create models that can be regenerated. First, get a reference to the original object. Then, make a copy of the object and insert the copy by setting its [Parent](/docs/reference/engine/classes/Instance#Parent) to the [Workspace](/docs/reference/engine/classes/Workspace) or one of its descendants. Finally, when it's time to regenerate the model, [Destroy](/docs/reference/engine/classes/Instance#Destroy) the copy and clone a new one from the original like before. #### Returns [Instance](/docs/reference/engine/classes/Instance) #### Code Samples This code first references an existing object in the original variable. Then, it makes a copy of the object, sets the parent to that of the original, and finally moves the copy to (0, 50, 0). Clone Example * * * -- Get a reference to an existing object local original = workspace.Model -- Create the model copy local copy = original:Clone() -- Parent the copy to the same parent as the original copy.Parent = original.Parent -- Move the copy so it's not overlapping the original copy:SetPrimaryPartCFrame(CFrame.new(0, 50, 0)) ### Destroy void Sets the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property to nil, locks the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property, disconnects all connections, and calls Destroy on all children. This function is the correct way to dispose of objects that are no longer required. Disposing of unneeded objects is important, since unnecessary objects and connections in a place use up memory (this is called a memory leak) which can lead to serious performance issues over time. Tip: After calling Destroy on an object, set any variables referencing the object (or its descendants) to nil. This prevents your code from accessing anything to do with the object. * * * local part = Instance.new("Part") part.Name = "Hello, world" part:Destroy() -- Don't do this: print(part.Name) --> "Hello, world" -- Do this to prevent the above line from working: part = nil Once an [Instance](/docs/reference/engine/classes/Instance) has been destroyed by this method it cannot be reused because the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property is locked. To temporarily remove an object, set [Parent](/docs/reference/engine/classes/Instance#Parent) it to nil instead. For example: * * * object.Parent = nil wait(2) object.Parent = workspace To Destroy an object after a set amount of time, use [Debris:AddItem()](/docs/reference/engine/classes/Debris#AddItem). #### Returns void #### Code Samples Instance:Destroy * * * local Part = workspace.Part Part:Destroy() Part.Parent = workspace --> The Parent property of Part is locked ### FindFirstAncestor [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.Name](/docs/reference/engine/classes/Instance#Name) is equal to the given name. This function works upwards, meaning it starts at the [Instance](/docs/reference/engine/classes/Instance)'s immediate [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) and works up towards the [DataModel](/docs/reference/engine/classes/DataModel). If no matching ancestor is found, it returns nil. The following code snippet would find the first ancestor of the object named 'Car'. * * * local car = object:FindFirstAncestor("Car") For variants of this function that find ancestors of a specific class, please see [Instance:FindFirstAncestorOfClass()](/docs/reference/engine/classes/Instance#FindFirstAncestorOfClass) and [Instance:FindFirstAncestorWhichIsA()](/docs/reference/engine/classes/Instance#FindFirstAncestorWhichIsA). #### Parameters name: [string](/docs/luau/strings) The [Instance.Name](/docs/reference/engine/classes/Instance#Name) to be looked for. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. ### FindFirstAncestorOfClass [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) is equal to the given className. This function works upwards, meaning it starts at the [Instance](/docs/reference/engine/classes/Instance)'s immediate [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) and works up towards the [DataModel](/docs/reference/engine/classes/DataModel). If no matching ancestor is found, it returns nil. A common use of this function is finding the [Model](/docs/reference/engine/classes/Model) a [BasePart](/docs/reference/engine/classes/BasePart) belongs to. For example: * * * local model = part:FindFirstAncestorOfClass("Model") This function is a variant of [Instance:FindFirstAncestor()](/docs/reference/engine/classes/Instance#FindFirstAncestor) which checks the [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) property rather than [Instance.Name](/docs/reference/engine/classes/Instance#Name). [Instance:FindFirstAncestorWhichIsA()](/docs/reference/engine/classes/Instance#FindFirstAncestorWhichIsA) also exists, using the [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) method instead to respect class inheritance. #### Parameters className: [string](/docs/luau/strings) The [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) to be looked for. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. ### FindFirstAncestorWhichIsA [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first ancestor of the [Instance](/docs/reference/engine/classes/Instance) for whom [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) returns true for the given className. This function works upwards, meaning it starts at the [Instance](/docs/reference/engine/classes/Instance)'s immediate [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) and works up towards the [DataModel](/docs/reference/engine/classes/DataModel). If no matching ancestor is found, it returns nil. Unlike [Instance:FindFirstAncestorOfClass()](/docs/reference/engine/classes/Instance#FindFirstAncestorOfClass), this function uses [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) which respects class inheritance. For example: * * * print(part:IsA("Part")) --> true print(part:IsA("BasePart")) --> true print(part:IsA("Instance")) --> true Therefore, the following code sample will return the first [BasePart](/docs/reference/engine/classes/BasePart) ancestor, regardless of if it is a [WedgePart](/docs/reference/engine/classes/WedgePart), [MeshPart](/docs/reference/engine/classes/MeshPart) or [Part](/docs/reference/engine/classes/Part). * * * local part = object:FindFirstAncestorWhichIsA("BasePart") See also, [Instance:FindFirstAncestor()](/docs/reference/engine/classes/Instance#FindFirstAncestor). #### Parameters className: [string](/docs/luau/strings) The [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) to be looked for. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. ### FindFirstChild [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) with the given name, or nil if no such child exists. If the optional recursive argument is true, this function searches all descendants rather than only the immediate children of the [Instance](/docs/reference/engine/classes/Instance). #### Checking the Existence of an Object FindFirstChild is necessary if you need to verify an object exists before continuing. Attempting to index a child by name using the dot operator throws an error if the child doesn't exist. * * * -- The following line errors if Part doesn't exist in the Workspace: workspace.Part.Transparency = 0.5 Use FindFirstChild to first check for Part, then use an if-statement to run code that needs it. * * * local part = workspace:FindFirstChild("Part") if part then part.Transparency = 0.5 end #### Finding a Child Whose Name Matches a Property Sometimes the [Name](/docs/reference/engine/classes/Instance#Name) of an object is the same as that of a property of its [Parent](/docs/reference/engine/classes/Instance#Parent). When using the dot operator, properties take precedence over children if they share a name. In the following example, a [Folder](/docs/reference/engine/classes/Folder) called "Color" is added to a [Part](/docs/reference/engine/classes/Part), which also has the [Part.Color](/docs/reference/engine/classes/Part#Color) property. [Part.Color](/docs/reference/engine/classes/Part#Color) refers to the [Color3](/docs/reference/engine/datatypes/Color3), not the Folder. * * * local part = Instance.new("Part") local folder = Instance.new("Folder") folder.Name = "Color" folder.Parent = part local c = part.Color --> A Color3 local c2 = part:FindFirstChild("Color") --> The Folder A benefit of using [FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) in this way is that the introduction of new properties does not impose a risk on your code. #### Performance Note [FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) takes about 20% longer than using the dot operator and almost 8 times longer than simply storing a reference to an object. Therefore, you should avoid calling it in performance-dependent code such as in tight loops or functions connected to [RunService.Heartbeat](/docs/reference/engine/classes/RunService#Heartbeat) and [RunService.RenderStepped](/docs/reference/engine/classes/RunService#RenderStepped). Instead, store the result in a variable, or consider using [ChildAdded](/docs/reference/engine/classes/Instance#ChildAdded) or [WaitForChild()](/docs/reference/engine/classes/Instance#WaitForChild) to detect when a child of a given name becomes available. #### Parameters name: [string](/docs/luau/strings) The [Instance.Name](/docs/reference/engine/classes/Instance#Name) to be searched for. recursive: [boolean](/docs/luau/booleans) Whether or not the search should be conducted recursively. Default Value: false #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. #### Code Samples The below would look in Workspace for an object name "Brick". If found, it will change the name of the object to "Foo". Instance:FindFirstChild * * * local found = workspace:FindFirstChild("Brick") if found then found.Name = "Foo" end ### FindFirstChildOfClass [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) whose [ClassName](/docs/reference/engine/classes/Instance#ClassName) is equal to the given className. If no matching child is found, this function returns nil. Unlike [Instance:FindFirstChildWhichIsA()](/docs/reference/engine/classes/Instance#FindFirstChildWhichIsA) this function uses only returns objects whose class matches the given className, ignoring class inheritance. Developers looking for a child by name should use [Instance:FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) instead. #### Parameters className: [string](/docs/luau/strings) The [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) to be looked for. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. #### Code Samples Instance:FindFirstChildOfClass * * * local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid while not humanoid do humanoid = character:FindFirstChildOfClass("Humanoid") if not humanoid then character.ChildAdded:Wait() end end ### FindFirstChildWhichIsA [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first child of the [Instance](/docs/reference/engine/classes/Instance) for whom [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) returns true for the given className. If no matching child is found, this function returns nil. If the optional recursive argument is true, this function searches all descendants rather than only the immediate children of the [Instance](/docs/reference/engine/classes/Instance). Unlike [Instance:FindFirstChildOfClass()](/docs/reference/engine/classes/Instance#FindFirstChildOfClass), this function uses [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) which respects class inheritance. For example: * * * print(part:IsA("Part")) --> true print(part:IsA("BasePart")) --> true print(part:IsA("Instance")) --> true Therefore, the following code sample will return the first [BasePart](/docs/reference/engine/classes/BasePart) child, regardless of if it is a [WedgePart](/docs/reference/engine/classes/WedgePart), [MeshPart](/docs/reference/engine/classes/MeshPart) or [Part](/docs/reference/engine/classes/Part). * * * local part = object:FindFirstChildWhichIsA("BasePart") Developers looking for a child by name, should use [Instance:FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) instead. #### Parameters className: [string](/docs/luau/strings) The [Instance.ClassName](/docs/reference/engine/classes/Instance#ClassName) to be searched for. recursive: [boolean](/docs/luau/booleans) Whether or not the search should be conducted recursively. Default Value: false #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. ### FindFirstDescendant [Instance](/docs/reference/engine/classes/Instance) [Write Parallel](/docs/scripting/multithreading) Returns the first descendant found with the given [Instance.Name](/docs/reference/engine/classes/Instance#Name). #### Parameters name: [string](/docs/luau/strings) The [Instance.Name](/docs/reference/engine/classes/Instance#Name) to search for. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. ### GetActor [Actor](/docs/reference/engine/classes/Actor) [Write Parallel](/docs/scripting/multithreading) If the [Instance](/docs/reference/engine/classes/Instance) is an [Actor](/docs/reference/engine/classes/Actor), the [Actor](/docs/reference/engine/classes/Actor) itself is returned. Otherwise, its closest ancestor [Actor](/docs/reference/engine/classes/Actor) is returned. If no ancestor is an [Actor](/docs/reference/engine/classes/Actor), the result is nil. #### Returns [Actor](/docs/reference/engine/classes/Actor) The [Actor](/docs/reference/engine/classes/Actor) found. ### GetAttribute Variant [Write Parallel](/docs/scripting/multithreading) This function returns the attribute which has been assigned to the given name. If no attribute has been assigned then nil is returned. For example, the following code snippet will set the value of the instance's InitialPostion attribute. Note that this code sample does not define [Instance](/docs/reference/engine/classes/Instance): * * * local initialPosition = instance:GetAttribute("InitialPosition") See also: * [Instance:SetAttribute()](/docs/reference/engine/classes/Instance#SetAttribute), sets the attribute with the given name to the given value * [Instance:GetAttributes()](/docs/reference/engine/classes/Instance#GetAttributes), returns a dictionary of string → variant pairs for each of the instance's attributes * [Instance.AttributeChanged](/docs/reference/engine/classes/Instance#AttributeChanged), fires whenever an attribute is changed on the instance * [Instance:GetAttributeChangedSignal()](/docs/reference/engine/classes/Instance#GetAttributeChangedSignal), returns an event that fires when the given attribute changes #### Parameters attribute: [string](/docs/luau/strings) The name of the attribute being retrieved. #### Returns Variant The attribute which has been assigned to the given name. If no attribute has been assigned then nil is returned. ### GetAttributeChangedSignal [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal) This function returns an event that behaves exactly like the Changed event, except that the event only fires when the given attribute changes. It's generally a good idea to use this method instead of a connection to Changed with a function that checks the attribute name. Subsequent calls to this method on the same object with the same attribute name return the same event. It is similar to [Instance:GetPropertyChangedSignal()](/docs/reference/engine/classes/Instance#GetPropertyChangedSignal) but for attributes. For example, the following code snippet will return a signal that fires the function [Instance.AttributeChanged](/docs/reference/engine/classes/Instance#AttributeChanged) when the instance's InitialPosition attribute changes. Note that this code sample does not define [Instance](/docs/reference/engine/classes/Instance): * * * local function attributeChanged() print("Attribute changed") end instance:GetAttributeChangedSignal("InitialPosition"):Connect(attributeChanged) See also: * [Instance:SetAttribute()](/docs/reference/engine/classes/Instance#SetAttribute), sets the attribute with the given name to the given value * [Instance:GetAttribute()](/docs/reference/engine/classes/Instance#GetAttribute), returns the attribute which has been assigned to the given name * [Instance:GetAttributes()](/docs/reference/engine/classes/Instance#GetAttributes), returns a dictionary of string → variant pairs for each of the instance's attributes * [Instance.AttributeChanged](/docs/reference/engine/classes/Instance#AttributeChanged), fires whenever an attribute is changed on the instance #### Parameters attribute: [string](/docs/luau/strings) The name of the specified attribute for which the change signal is being returned. #### Returns [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal) An event that fires when the given attribute changes. ### GetAttributes [table](/docs/luau/tables) [Write Parallel](/docs/scripting/multithreading) This function returns a dictionary of string → variant pairs for each attribute where the string is the name of the attribute and the variant is a non-nil value. For example, the following code snippet will print an instance's attributes and values. Note that this code sample does not define [Instance](/docs/reference/engine/classes/Instance): * * * local attributes = instance:GetAttributes() for name, value in pairs(attributes) do print(name .. " " .. value) end See also: * [Instance:SetAttribute()](/docs/reference/engine/classes/Instance#SetAttribute), sets the attribute with the given name to the given value * [Instance:GetAttribute()](/docs/reference/engine/classes/Instance#GetAttribute), returns the attribute which has been assigned to the given name * [Instance.AttributeChanged](/docs/reference/engine/classes/Instance#AttributeChanged), fires whenever an attribute is changed on the instance * [Instance:GetAttributeChangedSignal()](/docs/reference/engine/classes/Instance#GetAttributeChangedSignal), returns an event that fires when the given attribute changes #### Returns [table](/docs/luau/tables) A dictionary of string → variant pairs for each attribute where the string is the name of the attribute and the variant is a non-nil value. ### GetChildren [Objects](/docs/luau/tuples) [Write Parallel](/docs/scripting/multithreading) Returns an array (a numerically indexed table) containing all of the [Instance](/docs/reference/engine/classes/Instance)'s direct children, or every [Instance](/docs/reference/engine/classes/Instance) whose [Parent](/docs/reference/engine/classes/Instance#Parent) is equal to the object. The array can be iterated upon using either a numeric or generic for-loop: * * * -- Numeric for-loop example local children = workspace:GetChildren() for i = 1, #children do local child = children[i] print(child.Name .. " is child number " .. i) end * * * -- Generic for-loop example local children = workspace:GetChildren() for i, child in ipairs(children) do print(child.Name .. " is child number " .. i) end The children are sorted by the order in which their [Parent](/docs/reference/engine/classes/Instance#Parent) property was set to the object. See also the [GetDescendants](/docs/reference/engine/classes/Instance#GetDescendants) function. #### Returns [Objects](/docs/luau/tuples) An array containing the [Instance](/docs/reference/engine/classes/Instance)'s children. #### Code Samples The below would print the name of all objects currently in Workspace when ran. Instance:GetChildren * * * local children = workspace:GetChildren() for i = 1, #children do print(i, children[i].Name) end ### GetDebugId [string](/docs/luau/strings) Not Browsable Plugin Security Returns a coded string of the [Instance](/docs/reference/engine/classes/Instance)s DebugId used internally by Roblox. Note: * This item is protected. Attempting to use it in a [Script](/docs/reference/engine/classes/Script) or [LocalScript](/docs/reference/engine/classes/LocalScript) will cause an error * A debug ID is an ID used in debugging processes. It allows a debugger to read each instruction before an application processes it. All objects in Roblox act like processes and each run instructions (or 'code') that can be debugged if needed * This can be helpful for plugins which need to distinguish similar objects from one-another (such as objects that share the same name) #### Parameters scopeLength: [number](/docs/luau/numbers) The scope length. Default Value: 4 #### Returns [string](/docs/luau/strings) The Debug ID string. #### Code Samples Instance:GetDebugId * * * print(workspace:GetDebugId()) --> 39FA_12 print(workspace:GetDebugId(10)) --> 39FA2FEF4D_12 print(workspace:GetDebugId(math.huge)) --> 12 ### GetDescendants [Array](/docs/luau/tables) Custom Lua State [Write Parallel](/docs/scripting/multithreading) The GetDescendants function of an object returns an array that contains all of the descendants of that object. Unlike [Instance:GetChildren()](/docs/reference/engine/classes/Instance#GetChildren), which only returns the immediate children of an object, GetDescendants will find every child of the object, every child of those children, and so on. The arrays returned by GetDescendants are arranged so that parents come earlier than their children. Refer to the following example of a [Model](/docs/reference/engine/classes/Model) in the [Workspace](/docs/reference/engine/classes/Workspace): ![Workspace Descendants](https://prod.docsiteassets.roblox.com/assets/legacy/GetDescendantsExample.png) Inside this model are three parts (C, D, and E) and another model (InnerModel). Inside the inner model are two more parts (A and B). Calling GetDescendants on the first model and printing the contents of the returned array would print the first level of children (InnerModel, C, D, and E) before A and B. * * * local descendants = game.Workspace.Model:GetDescendants() -- Loop through all of the descendants of the model and -- print out their name for index, descendant in pairs(descendants) do print(descendant.Name) end -- Prints: -- C -- D -- E -- InnerModel -- A -- B #### Returns [Array](/docs/luau/tables) An array containing the [Instance](/docs/reference/engine/classes/Instance)'s descendants. #### Code Samples GetDescendants is often used to do something to all the descendants that are a particular type of object. The code in this example uses GetDescendants and [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) to find all of the parts in the workspace and turns them green. Instance:GetDescendants * * * local descendants = workspace:GetDescendants() -- Loop through all of the descendants of the Workspace. If a -- BasePart is found, the code changes that parts color to green for _, descendant in pairs(descendants) do if descendant:IsA("BasePart") then descendant.BrickColor = BrickColor.Green() end end ### GetFullName [string](/docs/luau/strings) [Write Parallel](/docs/scripting/multithreading) Returns a string describing the [Instance](/docs/reference/engine/classes/Instance)'s ancestry. The string is a concatenation of the [Name](/docs/reference/engine/classes/Instance#Name) of the object and its ancestors, separated by periods. The [DataModel](/docs/reference/engine/classes/DataModel) (game) is not considered. For example, a [Part](/docs/reference/engine/classes/Part) in the [Workspace](/docs/reference/engine/classes/Workspace) may return [Workspace.Part](/docs/reference/engine/classes/Workspace#Part). When called on an [Instance](/docs/reference/engine/classes/Instance) that is not a descendant of the [DataModel](/docs/reference/engine/classes/DataModel), this function considers all ancestors up to and including the topmost one without a [Parent](/docs/reference/engine/classes/Instance#Parent). This function is useful for logging and debugging. You shouldn't attempt to parse the returned string for any useful operation; this function does not escape periods (or any other symbol) in object names. In other words, although its output often appears to be a valid Lua identifier, it is not guaranteed. #### Returns [string](/docs/luau/strings) The full name of the [Instance](/docs/reference/engine/classes/Instance). #### Code Samples This code sample demonstrates the behavior of [Instance:GetFullName()](/docs/reference/engine/classes/Instance#GetFullName). It shows how the function behaves when called on an object not in the DataModel hierarchy, and it also shows how the return value does not escape special characters. Instance:GetFullName * * * -- Create a simple hierarchy local model = Instance.new("Model") local part = Instance.new("Part") part.Parent = model local fire = Instance.new("Fire") fire.Parent = part print(fire:GetFullName()) --> Model.Part.Fire model.Parent = workspace print(fire:GetFullName()) --> Workspace.Model.Part.Fire part.Name = "Hello, world" print(fire:GetFullName()) --> Workspace.Model.Hello, world.Fire This code sample re-implements the [Instance:GetFullName()](/docs/reference/engine/classes/Instance#GetFullName) function in Lua. Instance:GetFullName Lua Implementation * * * local function getFullName(object) local result = object.Name object = object.Parent while object and object ~= game do -- Prepend parent name result = object.Name .. "." .. result -- Go up the hierarchy object = object.Parent end return result end print(getFullName(workspace.Camera)) --> Workspace.Camera ### GetPropertyChangedSignal [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal) This method returns an event that behaves exactly like the Changed event, except that the event only fires when the given property changes. It's generally a good idea to use this method instead of a connection to Changed with a function that checks the property name. Subsequent calls to this method on the same object with the same property name return the same event. print(object:GetPropertyChangedSignal("Name") == object:GetPropertyChangedSignal("Name")) --> always true [ValueBase](/docs/reference/engine/classes/ValueBase) objects, such as [IntValue](/docs/reference/engine/classes/IntValue) and [StringValue](/docs/reference/engine/classes/StringValue), use a modified Changed event that fires with the contents of the Value property. As such, this method provides a way to detect changes in other properties of those objects. For example, to detect changes in the Name property of an [IntValue](/docs/reference/engine/classes/IntValue), use IntValue:GetPropertyChangedSignal("Name"):Connect(someFunc) since the Changed event of [IntValue](/docs/reference/engine/classes/IntValue) objects only detect changes on the Value property. #### Parameters property: [string](/docs/luau/strings) The property to connect to. #### Returns [RBXScriptSignal](/docs/reference/engine/datatypes/RBXScriptSignal) A signal that fires whenever the property changes. #### Code Samples This code sample demonstrates how to save a value before a changed event fires on it in order to get more information about a change. Old-to-New Values with Changed * * * local part = Instance.new("Part") local currentColor = part.BrickColor local function onBrickColorChanged() local newColor = part.BrickColor print("Color changed from", currentColor.Name, "to", newColor.Name) currentColor = newColor end part:GetPropertyChangedSignal("BrickColor"):Connect(onBrickColorChanged) part.BrickColor = BrickColor.new("Really red") part.BrickColor = BrickColor.new("Really blue") This code sample demonstrates the equivalence of the Changed event and event returned by GetPropertyChangedSignal. Changed and GetPropertyChangedSignal * * * local part = Instance.new("Part") local function onBrickColorChanged() print("My color is now " .. part.BrickColor.Name) end local function onChanged(property) if property == "BrickColor" then onBrickColorChanged() end end part:GetPropertyChangedSignal("BrickColor"):Connect(onBrickColorChanged) part.Changed:Connect(onChanged) -- Trigger some changes (because we connected twice, -- both of these will cause two calls to onBrickColorChanged) part.BrickColor = BrickColor.new("Really red") part.BrickColor = BrickColor.new("Institutional white") ### GetTags [Array](/docs/luau/tables) [Write Parallel](/docs/scripting/multithreading) This method returns an array of the tags applied to the given instance, as strings. You can add tags either in Studio in the [Properties](https://prod.docsiteassets.roblox.com/studio/properties.md) window or at runtime with [AddTag()](/docs/reference/engine/classes/Instance#AddTag). This method is useful when you want to do something with multiple tags on an instance at once. However, it is inefficient to use this method to check for the existence of a single tag; instead, use [HasTag()](/docs/reference/engine/classes/Instance#HasTag) to check for a specific tag. #### Returns [Array](/docs/luau/tables) ### HasTag [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) This method returns true if the provided tag has been added to the object. You can add tags either in Studio in the [Properties](https://prod.docsiteassets.roblox.com/studio/properties.md) window or at runtime with [AddTag()](/docs/reference/engine/classes/Instance#AddTag). #### Parameters tag: [string](/docs/luau/strings) #### Returns [boolean](/docs/luau/booleans) ### IsA [boolean](/docs/luau/booleans) Custom Lua State [Write Parallel](/docs/scripting/multithreading) IsA returns true if the [Instance](/docs/reference/engine/classes/Instance)'s class is equivalent to or a subclass of a given class. This function is similar to the instanceof operators in other languages, and is a form of [type introspection](https://en.wikipedia.org/wiki/Type_introspection). To ignore class inheritance, test the [ClassName](/docs/reference/engine/classes/Instance#ClassName) property directly instead. For checking native Lua data types (number, string, etc) use the functions type and typeof. Most commonly, this function is used to test if an object is some kind of part, such as [Part](/docs/reference/engine/classes/Part) or [WedgePart](/docs/reference/engine/classes/WedgePart), which inherits from [BasePart](/docs/reference/engine/classes/BasePart) (an abstract class). For example, if your goal is to change all of a [Character](/docs/reference/engine/classes/Player#Character)'s limbs to the same color, you might use [GetChildren](/docs/reference/engine/classes/Instance#GetChildren) to iterate over the children, then use IsA to filter non-[BasePart](/docs/reference/engine/classes/BasePart) objects which lack the [BrickColor](/docs/reference/engine/datatypes/BrickColor) property: * * * local function paintFigure(character, color) -- Iterate over the child objects of the character for _, child in pairs(character:GetChildren()) do -- Filter out non-part objects, such as Shirt, Pants and Humanoid -- R15 use MeshPart and R6 use Part, so we use BasePart here to detect both: if child:IsA("BasePart") then child.BrickColor = color end end end paintFigure(game.Players.Player.Character, BrickColor.new("Bright blue")) Since all classes inherit from [Instance](/docs/reference/engine/classes/Instance), calling object:IsA("Instance") will always return true. #### Parameters className: [string](/docs/luau/strings) The class against which the Instance's class will be checked. Case-sensitive. #### Returns [boolean](/docs/luau/booleans) Describes whether the Instance's class matched or is a subclass of the given class. #### Code Samples Usage of IsA to test class inheritance: Instance:IsA * * * print(workspace:IsA("Instance")) --> true print(workspace:IsA("Workspace")) --> true print(game:IsA("workspace")) --> false print(game:IsA("DataModel")) --> true ### IsAncestorOf [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) Returns true if an [Instance](/docs/reference/engine/classes/Instance) is an ancestor of the given descendant. An [Instance](/docs/reference/engine/classes/Instance) is considered the ancestor of an object if the object's [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) or one of it's parent's [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) is set to the [Instance](/docs/reference/engine/classes/Instance). See also, [Instance:IsDescendantOf()](/docs/reference/engine/classes/Instance#IsDescendantOf). #### Parameters descendant: [Instance](/docs/reference/engine/classes/Instance) The descendant [Instance](/docs/reference/engine/classes/Instance). #### Returns [boolean](/docs/luau/booleans) True if the [Instance](/docs/reference/engine/classes/Instance) is an ancestor of the given descendant. #### Code Samples Instance:IsAncestorOf * * * print(workspace:IsAncestorOf(workspace.Player.HumanoidRootPart)) --> true ### IsDescendantOf [boolean](/docs/luau/booleans) [Write Parallel](/docs/scripting/multithreading) Returns true if an [Instance](/docs/reference/engine/classes/Instance) is a descendant of the given ancestor. An [Instance](/docs/reference/engine/classes/Instance) is considered the descendant of an object if the [Instance](/docs/reference/engine/classes/Instance)'s parent or one of its parent's parent is set to the object. Note, [DataModel](/docs/reference/engine/classes/DataModel) is a descendant of nil. This means IsDescendantOf cannot be used with a parameter of nil to check if an object has been removed. See also, [Instance:IsAncestorOf()](/docs/reference/engine/classes/Instance#IsAncestorOf). #### Parameters ancestor: [Instance](/docs/reference/engine/classes/Instance) The ancestor [Instance](/docs/reference/engine/classes/Instance). #### Returns [boolean](/docs/luau/booleans) True if the [Instance](/docs/reference/engine/classes/Instance) is a descendant of the given ancestor. #### Code Samples Instance:IsDescendantOf * * * local part = Instance.new("Part") print(part:IsDescendantOf(game)) --> false part.Parent = workspace print(part:IsDescendantOf(game)) --> true part.Parent = game print(part:IsDescendantOf(game)) --> true ### Remove void DEPRECATED DEPRECATED This item is deprecated in favor of [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy) and [Instance:ClearAllChildren()](/docs/reference/engine/classes/Instance#ClearAllChildren). If you must remove an object from the game, and wish to use the object later, set its Parent property to nil instead of using this method. The Remove function sets the object's [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) to nil, and does the same for all its descendants. If the object is referenced before being removed it is possible to retrieve the object at a later point. #### Returns void #### Code Samples The following code demonstrates how a part can be re-added to the DataModel after being removed: Instance:Remove * * * local part = Instance.new("Part") part.Parent = workspace print(part.Parent) --> Workspace part:Remove() print(part.Parent) --> nil part.Parent = workspace print(part.Parent) --> Workspace ### RemoveTag void This method removes a tag from an instance. It will not throw an error if the object does not have the tag. Successfully removing a tag will fire a signal created by [CollectionService:GetInstanceRemovedSignal()](/docs/reference/engine/classes/CollectionService#GetInstanceRemovedSignal) with the given tag. Note that when tagging an instance, it's common that some resources are used to give the tag its functionality, for example event connections or tables. To prevent memory leaks, it's a good idea to clean these up (disconnect, set to nil, etc.) when no longer needed for a tag. #### Parameters tag: [string](/docs/luau/strings) #### Returns void ### SetAttribute void This function sets the attribute with the given name to the given value. If the value given is nil, then the attribute will be removed (since nil is returned by default). For example, the following code snippet will set the instance's InitialPosition attribute to [Vector3.new(0, 0, 0)](/docs/reference/engine/datatypes/Vector3). Note that this code sample does not define [Instance](/docs/reference/engine/classes/Instance): * * * instance:SetAttribute("InitialPosition", Vector3.new(0, 0, 0)) #### Limitations Naming requirements and restrictions: * Names must only use alphanumeric characters and underscore * No spaces or unique symbols are allowed * Strings must be 100 characters or less * Names are not allowed to start with RBX unless the caller is a Roblox core-script (reserved for Roblox) When attempting to set an attribute to an unsupported type, an error will be thrown. See also: * [Instance:GetAttribute()](/docs/reference/engine/classes/Instance#GetAttribute), returns the attribute which has been assigned to the given name * [Instance:GetAttributes()](/docs/reference/engine/classes/Instance#GetAttributes), returns a dictionary of string → variant pairs for each of the instance's attributes * [Instance.AttributeChanged](/docs/reference/engine/classes/Instance#AttributeChanged), fires whenever an attribute is changed on the instance * [Instance:GetAttributeChangedSignal()](/docs/reference/engine/classes/Instance#GetAttributeChangedSignal), returns an event that fires when the given attribute changes #### Parameters attribute: [string](/docs/luau/strings) The name of the attribute being set. value: Variant The value that the specified attribute is being set to. #### Returns void ### WaitForChild [Instance](/docs/reference/engine/classes/Instance) Custom Lua State Can Yield Returns the child of the [Instance](/docs/reference/engine/classes/Instance) with the given name. If the child does not exist, it will yield the current thread until it does. If the timeOut parameter is specified, this method will time out after the specified number of seconds and return nil. #### Primary Usage [WaitForChild()](/docs/reference/engine/classes/Instance#WaitForChild) is extremely important when working on code run by the client in a [LocalScript](/docs/reference/engine/classes/LocalScript). The Roblox engine does not guarantee the time or order in which objects are replicated from the server to the client. Additionally, if an experience has [Workspace.StreamingEnabled](/docs/reference/engine/classes/Workspace#StreamingEnabled) set to true, [BaseParts](/docs/reference/engine/classes/BasePart) that are far away from the player's character may not be streamed to the client, potentially causing scripts to break when indexing objects that do not yet exist on the client. #### Notes * This function does not yield if a child with the given name exists when the call is made. * [Instance:FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) is a more efficient alternative to [WaitForChild()](/docs/reference/engine/classes/Instance#WaitForChild) for objects that are assumed to exist. * If a call to this method exceeds 5 seconds without returning, and no timeOut parameter has been specified, a warning will be printed to the output that the thread may yield indefinitely. This warning takes the following form where X is the parent's name and Y is the child's name: Infinite yield possible on 'X:WaitForChild("Y")' #### Parameters childName: [string](/docs/luau/strings) The [Instance.Name](/docs/reference/engine/classes/Instance#Name) to be looked for. timeOut: [number](/docs/luau/numbers) An optional time out parameter. #### Returns [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) found. #### Code Samples The following code waits for an instance named "Part" to be added to Workspace. Instance:WaitForChild * * * local part = workspace:WaitForChild("Part") print(part.Name .. " has been added to the Workspace") ### children [Objects](/docs/luau/tuples) DEPRECATED DEPRECATED This item has been superseded by [Instance:GetChildren()](/docs/reference/engine/classes/Instance#GetChildren) which should be used in all new work. The children function returns an array of the object's children. #### Returns [Objects](/docs/luau/tuples) Array of child objects/instances. ### clone [Instance](/docs/reference/engine/classes/Instance) DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:Clone()](/docs/reference/engine/classes/Instance#Clone) which should be used instead. #### Returns [Instance](/docs/reference/engine/classes/Instance) ### destroy void DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy) which should be used instead. #### Returns void ### findFirstChild [Instance](/docs/reference/engine/classes/Instance) DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:FindFirstChild()](/docs/reference/engine/classes/Instance#FindFirstChild) which should be used instead. #### Parameters name: [string](/docs/luau/strings) recursive: [boolean](/docs/luau/booleans) Default Value: false #### Returns [Instance](/docs/reference/engine/classes/Instance) ### getChildren [Objects](/docs/luau/tuples) DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:GetChildren()](/docs/reference/engine/classes/Instance#GetChildren) which should be used instead. #### Returns [Objects](/docs/luau/tuples) ### isA [boolean](/docs/luau/booleans) DEPRECATED Custom Lua State DEPRECATED This deprecated function is a variant of [Instance:IsA()](/docs/reference/engine/classes/Instance#IsA) which should be used instead. #### Parameters className: [string](/docs/luau/strings) #### Returns [boolean](/docs/luau/booleans) ### isDescendantOf [boolean](/docs/luau/booleans) DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:IsDescendantOf()](/docs/reference/engine/classes/Instance#IsDescendantOf) which should be used instead. #### Parameters ancestor: [Instance](/docs/reference/engine/classes/Instance) #### Returns [boolean](/docs/luau/booleans) ### remove void DEPRECATED DEPRECATED This deprecated function is a variant of [Instance:Remove()](/docs/reference/engine/classes/Instance#Remove) which has also been deprecated. Neither function should be used in new work. #### Returns void Events ------ Events inherited from BasePart ### LocalSimulationTouched DEPRECATED DEPRECATED This event is deprecated in favor of [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched). Fired when another part comes in contact with another object. This event only sends data to the client notifying it that two parts have collided, whereas [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched) sends data to the server. #### Parameters part: [BasePart](/docs/reference/engine/classes/BasePart) #### Code Samples BasePart.LocalSimulationTouched * * * workspace.Part.LocalSimulationTouched:Connect(function(part) print(part.Name) end) ### OutfitChanged DEPRECATED DEPRECATED This event is deprecated. Do not use it for new work. Fired if the part's appearance is affected by the [Shirt](/docs/reference/engine/classes/Shirt) class. ### StoppedTouching DEPRECATED DEPRECATED This event is deprecated in favor of [BasePart.TouchEnded](/docs/reference/engine/classes/BasePart#TouchEnded), which should be used instead. #### Parameters otherPart: [BasePart](/docs/reference/engine/classes/BasePart) ### TouchEnded Fires when a part stops touching another part under similar conditions to those of [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched). This event works in conjunction with [Workspace.TouchesUseCollisionGroups](/docs/reference/engine/classes/Workspace#TouchesUseCollisionGroups) to specify whether [collision groups](/docs/workspace/collisions.md#collision-filtering) are acknowledged for detection. #### Parameters otherPart: [BasePart](/docs/reference/engine/classes/BasePart) #### Code Samples This code sample creates a BillboardGui on a part that displays the number of parts presently touching it. 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 The Touched event fires when a part comes in contact with another part. For instance, if PartA bumps into PartB, then [PartA.Touched](/docs/reference/engine/classes/BasePart#Touched) fires with PartB, and [PartB.Touched](/docs/reference/engine/classes/BasePart#Touched) fires with PartA. This event only fires as a result of physical movement, so it will not fire if the [CFrame](/docs/reference/engine/classes/BasePart#CFrame) property was changed such that the part overlaps another part. This also means that at least one of the parts involved must not be [Anchored](/docs/reference/engine/classes/BasePart#Anchored) at the time of the collision. This event works in conjunction with [Workspace.TouchesUseCollisionGroups](/docs/reference/engine/classes/Workspace#TouchesUseCollisionGroups) to specify whether [collision groups](/docs/workspace/collisions.md#collision-filtering) are acknowledged for detection. #### Parameters otherPart: [BasePart](/docs/reference/engine/classes/BasePart) The other part that came in contact with the given part. #### Code Samples This code sample creates a BillboardGui on a part that displays the number of parts presently touching it. 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) This code sample demonstrates how to connect the [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched) event of multiple parts in a [Model](/docs/reference/engine/classes/Model) to one function. 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 Events inherited from Instance ### AncestryChanged Fires when the [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) property of the object or one of its ancestors is changed. This event includes two parameters, _child_ and _parent_. _Child_ refers to the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) was actually changed. _Parent_ refers to this [Instance](/docs/reference/engine/classes/Instance)'s new [Instance.Parent](/docs/reference/engine/classes/Instance#Parent). You can use this event to track the deletion of an instance in Studio, such as manual deletion in the Explorer or through a plugin. If you need to detect when an instance is destroyed using [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy), use the [Instance.Destroying](/docs/reference/engine/classes/Instance#Destroying) event instead. #### Parameters child: [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) whose [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) has been changed. parent: [Instance](/docs/reference/engine/classes/Instance) The new [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) of the [Instance](/docs/reference/engine/classes/Instance) whose [Instance.Parent](/docs/reference/engine/classes/Instance#Parent) was changed. #### Code Samples The below example would print "Part is now a child of Model". Instance.AncestryChanged * * * local part = Instance.new("Part") part.Parent = workspace local function onAncestryChanged(child, parent) print(child.Name .. " is now a child of " .. parent.Name) end part.AncestryChanged:Connect(onAncestryChanged) part.Parent = workspace.Model ### AttributeChanged This event fires whenever an attribute is changed on the instance. This includes when an attribute is set to nil. The name of the attribute that has been changed is passed to the connected function. For example, the following code snippet will connect the AttributeChanged function to fire whenever one of [Instance](/docs/reference/engine/classes/Instance)'s attributes changes. Note that this code sample does not define [Instance](/docs/reference/engine/classes/Instance): * * * local function attributeChanged(attributeName) print(attributeName, "changed") end instance.AttributeChanged:Connect(attributeChanged) See also: * [Instance:SetAttribute()](/docs/reference/engine/classes/Instance#SetAttribute), sets the attribute with the given name to the given value * [Instance:GetAttribute()](/docs/reference/engine/classes/Instance#GetAttribute), returns the attribute which has been assigned to the given name * [Instance:GetAttributes()](/docs/reference/engine/classes/Instance#GetAttributes), returns a dictionary of string → variant pairs for each of the instance's attributes * [Instance:GetAttributeChangedSignal()](/docs/reference/engine/classes/Instance#GetAttributeChangedSignal), returns an event that fires when the given attribute changes #### Parameters attribute: [string](/docs/luau/strings) The name of the attribute that has been changed. ### Changed The Changed event fires right after most properties change on objects. It is possible to find the present value of a changed property by using object\[property\]. To get the value of a property before it changes, you must have stored the value of the property before it changed. If you are only interested in listening to the change of a specific property, consider using the GetPropertyChangedSignal method instead to get an event that only fires when a given property changes. This event does not fire for physics-related changes, like when the [CFrame](/docs/reference/engine/datatypes/CFrame), Velocity, RotVelocity, Position, Orientation and [CFrame](/docs/reference/engine/datatypes/CFrame) properties of a [BasePart](/docs/reference/engine/classes/BasePart) change due to gravity. To detect changes in these properties, consider using a physics-based event like [RunService.Stepped](/docs/reference/engine/classes/RunService#Stepped) or [BasePart.Touched](/docs/reference/engine/classes/BasePart#Touched). A while-true-do loop can also work. For "-Value" objects, this event behaves differently: it only fires when the Value property changes. See individual pages for [IntValue](/docs/reference/engine/classes/IntValue), [StringValue](/docs/reference/engine/classes/StringValue), etc for more information. To detect other changes in these objects, you must use GetPropertyChangedSignal instead. #### Parameters property: [string](/docs/luau/strings) The name of the property that changed. #### Code Samples This sample demonstrates the subtleties of the Changed event on normal objects and "-Value" objects. Changed Event * * * -- Demonstrate the Changed event by creating a Part local part = Instance.new("Part") part.Changed:Connect(print) -- This fires Changed with "Transparency" part.Transparency = 0.5 -- Similarly, this fires Changed with "Number" part.Name = "SomePart" -- Since changing BrickColor will also change other -- properties at the same time, this line fires Changed -- with "BrickColor", "Color3" and "Color3uint16". part.BrickColor = BrickColor.Red() -- A NumberValue holds a double-precision floating-point number local vNumber = Instance.new("NumberValue") vNumber.Changed:Connect(print) -- This fires Changed with 123.456 (not "Value") vNumber.Value = 123.456 -- This does not fire Changed vNumber.Name = "SomeNumber" -- A StringValue stores one string local vString = Instance.new("StringValue") vString.Changed:Connect(print) -- This fires Changed with "Hello" (not "Value") vString.Value = "Hello" This code sample demonstrates the Changed event firing within a parent object. Change Detector * * * local object = script.Parent local function onChanged(property) -- Get the current value of the property local value = object[property] -- Print a message saying what changed print(object:GetFullName() .. "." .. property .. " (" .. typeof(value) .. ") changed to " .. tostring(value)) end object.Changed:Connect(onChanged) -- Trigger a simple change in the object (add an underscore to the name) object.Name = "_" .. object.Name ### ChildAdded Fires after an object is parented to this [Instance](/docs/reference/engine/classes/Instance). Note, when using this function on a client to detect objects created by the server it is necessary to use [Instance:WaitForChild()](/docs/reference/engine/classes/Instance#WaitForChild) when indexing these object's descendants. This is because the object and its descendants are not guaranteed to replicate from the server to the client simultaneously. For example: * * * workspace.ChildAdded:Connect(function(child) -- need to use WaitForChild as descendants may not have replicated yet local head = child:WaitForChild("Head") end) Note, this function only works for immediate children of the [Instance](/docs/reference/engine/classes/Instance). For a function that captures all descendants, use [Instance.DescendantAdded](/docs/reference/engine/classes/Instance#DescendantAdded). See also, [Instance.ChildRemoved](/docs/reference/engine/classes/Instance#ChildRemoved). #### Parameters child: [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) that has been added. #### Code Samples This snippet prints the names of objects as they are added to the Workspace: Instance.ChildAdded * * * local function onChildAdded(instance) print(instance.Name .. " added to the workspace") end workspace.ChildAdded:Connect(onChildAdded) local part = Instance.new("Part") part.Parent = workspace --> Part added to the Workspace ### ChildRemoved Fires after a child is removed from this [Instance](/docs/reference/engine/classes/Instance). Removed refers to when an object's parent is changed from this [Instance](/docs/reference/engine/classes/Instance) to something other than this [Instance](/docs/reference/engine/classes/Instance). Note, this event will also fire when a child is destroyed (using [Instance:Destroy()](/docs/reference/engine/classes/Instance#Destroy)) as the destroy function sets an object's parent to nil. This function only works for immediate children of the [Instance](/docs/reference/engine/classes/Instance). For a function that captures all descendants, use [Instance.DescendantRemoving](/docs/reference/engine/classes/Instance#DescendantRemoving). See also [Instance.ChildAdded](/docs/reference/engine/classes/Instance#ChildAdded). #### Parameters child: [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) that has been removed. #### Code Samples This snippet prints the names of objects as they are removed from the Workspace: Instance.ChildRemoved * * * local function onChildRemoved(instance) print(instance.Name .. " removed from the workspace") end workspace.ChildRemoved:Connect(onChildRemoved) local part = Instance.new("Part") part.Parent = workspace task.wait(2) part:Destroy() ### DescendantAdded The DescendantAdded event fires after a descendant is added to the [Instance](/docs/reference/engine/classes/Instance). As DescendantAdded fires for every descendant, parenting an object to the [Instance](/docs/reference/engine/classes/Instance) will fire the event for this object and all of its descendants individually. Developers only concerned with the immediate children of the [Instance](/docs/reference/engine/classes/Instance) should use [Instance.ChildAdded](/docs/reference/engine/classes/Instance#ChildAdded) instead. See also [Instance.DescendantRemoving](/docs/reference/engine/classes/Instance#DescendantRemoving). #### Parameters descendant: [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) that has been added. #### Code Samples This following example will print the name of any object that is added to the Workspace: Instance.DescendantAdded * * * local function onDescendantAdded(descendant) print(descendant) end workspace.DescendantAdded:Connect(onDescendantAdded) local part = Instance.new("Part") part.Parent = workspace ### DescendantRemoving DescendantRemoving fires immediately before the [Parent](/docs/reference/engine/classes/Instance#Parent) of a descendant of the [Instance](/docs/reference/engine/classes/Instance) changes such that the object is no longer a descendant of the Instance. [Destroy](/docs/reference/engine/classes/Instance#Destroy) and [Remove](/docs/reference/engine/classes/Instance#Remove) change an object's Parent to nil, so calling these on a descendant of an object will therefore cause this event to fire. Since this event fires before the descendant's removal, the Parent of the descendant will be unchanged, i.e., it will still be a descendant at the time of this event firing. If the descendant is also a child of the object, It will also fire before ChildRemoved. There is no similar event called "DescendantRemoved". If a descendant has children, this event fires with the descendant first followed by its descendants. #### Example The example below should help clarify how DescendantRemoving fires when there are several objects involved. ![A cropped screenshot of the Explorer window. A Model contains ModelA and ModelB, which each contain a Part, PartA and PartB respectively. PartA contains a Fire object named FireA.](https://prod.docsiteassets.roblox.com/assets/legacy/DescendantRemoving2.png) * Calling [Remove](/docs/reference/engine/classes/Instance#Remove) on PartA would cause DescendantRemoving to fire on both ModelA and Model, in that order. * Setting the [Parent](/docs/reference/engine/classes/Instance#Parent) of PartA to ModelB would cause DescendantRemoving to fire on ModelA but not Model (as Model would still be an ancestor of PartA). * Calling [Destroy](/docs/reference/engine/classes/Instance#Destroy) on ModelA would cause DescendantRemoving to fire multiple times on several objects: 1. On Model with ModelA, PartA then FireA. 2. On ModelA, with PartA then FireA. 3. On PartA with FireA. #### Warning This event fires with the descendant object that is being removed. Attempting to set the [Parent](/docs/reference/engine/classes/Instance#Parent) of the descendant being removed to something else will fail with the following warning: "Something unexpectedly tried to set the parent of X to Y while trying to set the parent of X. Current parent is Z", where X is the removing descendant, Y is the ignored parent setting, and Z is the original parent of X. Below is an example that demonstrates this: * * * workspace.DescendantRemoving:Connect(function(descendant) -- Don't manipulate the parent of descendant in this function! -- This event fires BECAUSE the parent of descendant was manipulated, -- and the change hasn't happened yet, i.e. this function fires before that happens. -- Therefore, it is problematic to change the parent like this: descendant.Parent = game end) local part = Instance.new("Part") part.Parent = workspace part.Parent = nil -- This triggers DescendantRemoving on Workspace: --> Something unexpectedly tried to set the parent of Part to NULL while trying to set the parent of Part. Current parent is Workspace. See also [DescendantAdded](/docs/reference/engine/classes/Instance#DescendantAdded). #### Parameters descendant: [Instance](/docs/reference/engine/classes/Instance) The [Instance](/docs/reference/engine/classes/Instance) that is being removed. #### Code Samples The following example prints the name of any descendant as it is being removed from the Workspace: Instance.DescendantRemoving * * * workspace.DescendantRemoving:Connect(function(descendant) print(descendant.Name .. " is currently parented to " .. tostring(descendant.Parent)) end) local part = Instance.new("Part") part.Parent = workspace part.Parent = nil --> Part is currently parented to Workspace print(part.Parent) --> nil ### Destroying The Destroying event fires immediately before the Instance or one of its ancestors is destroyed with Instance.Destroy(). The Instance will never be deleted from memory while a connected function is still using it. However, if the function yields at any point, the Instance and its descendants will be parented to nil. When deleting an instance in Studio, such as manually deleting through the Explorer or through a plugin, the instance isn't destroyed. Instead, the parent is set to nil which you can track with [Instance.AncestryChanged](/docs/reference/engine/classes/Instance#AncestryChanged). #### Code Samples This sample demonstrates how an Instance being destroyed remains in place until the connected function yields. Using the Destroying Event * * * local part = Instance.new("Part", workspace) local function onPartDestroying() print("Before yielding:", part:GetFullName(), #part:GetChildren()) task.wait() print("After yielding:", part:GetFullName(), #part:GetChildren()) end part.Destroying:Connect(onPartDestroying) part:Destroy() ### childAdded DEPRECATED DEPRECATED This deprecated event is a variant of [Instance.ChildAdded](/docs/reference/engine/classes/Instance#ChildAdded) which should be used instead. #### Parameters child: [Instance](/docs/reference/engine/classes/Instance)