WorldRoot
WorldRoot : Instance
Overview
A WorldRoot is a class used for detecting or simulating Objects in 3D space
Properties
Methods
Blockcast
Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path, and returns the result as a RaycastResult object. It works like Raycast, but can detect a broader region of Objects as it detects collision in a box shape instead of a ray shape.
Parameters
CFrame InCFrame
The coordinate frame representing a box’s initial position and rotation.
Vector3 InExtents
A vector defining the size (width, length, height) of a box.
Vector3 InDirection
A vector representing the box’s movement direction; its length (size) also determines the detectable distance.
RaycastParams InRaycastParams
A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
RaycastResult
A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs.
Code Samples
BlockcastSingleByChannel
Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path based on the specified collision channel (TraceChannel), and returns the result as a RaycastResult object. It works like Blockcast, but performs collision detection based on a collision channel.
Parameters
CFrame InCFrame
The coordinate frame representing the box's initial position and rotation.
Vector3 InExtents
A vector defining the size (width, length, height) of the box.
Vector3 InDirection
A vector representing the box's movement direction; its length (size) also determines the detectable distance.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs.
Code Samples
BlockcastSingleByChannelName
Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path based on the name of the specified collision channel (ChannelDisplayName), and returns the result as a RaycastResult object. It works like BlockcastSingleByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls BlockcastSingleByChannel; if no channel matching the given name is found, it does not perform collision detection.
Parameters
CFrame InCFrame
The coordinate frame representing the box's initial position and rotation.
Vector3 InExtents
A vector defining the size (width, length, height) of the box.
Vector3 InDirection
A vector representing the box's movement direction; its length (size) also determines the detectable distance.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs or if no collision channel matching the given name is found.
Code Samples
BlockcastSingleByObject
Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path based on object query parameters, and returns the result as a RaycastResult object. It works like Blockcast, but performs collision detection based on object type.
Parameters
CFrame InCFrame
The coordinate frame representing a box's initial position and rotation.
Vector3 InExtents
A vector defining the size (width, length, height) of a box.
Vector3 InDirection
A vector representing the box's movement direction; its length (size) also determines the detectable distance.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
RaycastResult
A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs.
Code Samples
BlockcastSingleByProfile
Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path based on the specified collision profile (ProfileName), and returns the result as a RaycastResult object. It works like Blockcast, but performs collision detection based on a collision profile.
Parameters
CFrame InCFrame
The coordinate frame representing a box's initial position and rotation.
Vector3 InExtents
A vector defining the size (width, length, height) of a box.
Vector3 InDirection
A vector representing the box's movement direction; its length (size) also determines the detectable distance.
string ProfileName
The name of the collision profile used for collision detection. The detection targets are determined by the collision response settings of the profile.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
Return
RaycastResult
A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs.
Code Samples
Capsulecast
Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path, and returns the result as a RaycastResult object. Ideal for predicting character movement paths or collisions, as it detects collisions using capsule shape which resembles a character's form.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of a capsule.
number InRadius
The radius of a capsule.
number InHalfHeight
The height of a capsule.
Vector3 InDirection
A vector representing the capsule’s movement direction; its length (size) also determines the detectable distance.
RaycastParams InRaycastParams
A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
RaycastResult
A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs.
Code Samples
CapsulecastSingleByChannel
Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path based on the specified collision channel (TraceChannel), and returns the result as a RaycastResult object. It works like Capsulecast, but performs collision detection based on a collision channel.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of the capsule.
number InRadius
The radius of the capsule.
number InHalfHeight
The height of the capsule.
Vector3 InDirection
A vector representing the capsule's movement direction; its length (size) also determines the detectable distance.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs.
Code Samples
CapsulecastSingleByChannelName
Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path based on the name of the specified collision channel (ChannelDisplayName), and returns the result as a RaycastResult object. It works like CapsulecastSingleByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls CapsulecastSingleByChannel; if no channel matching the given name is found, it does not perform collision detection.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of the capsule.
number InRadius
The radius of the capsule.
number InHalfHeight
The height of the capsule.
Vector3 InDirection
A vector representing the capsule's movement direction; its length (size) also determines the detectable distance.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs or if no collision channel matching the given name is found.
Code Samples
CapsulecastSingleByObject
Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path based on object query parameters, and returns the result as a RaycastResult object. It works like Capsulecast, but performs collision detection based on object type.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of a capsule.
number InRadius
The radius of a capsule.
number InHalfHeight
The height of a capsule.
Vector3 InDirection
A vector representing the capsule's movement direction; its length (size) also determines the detectable distance.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
RaycastResult
A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs.
Code Samples
CapsulecastSingleByProfile
Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path based on the specified collision profile (ProfileName), and returns the result as a RaycastResult object. It works like Capsulecast, but performs collision detection based on a collision profile.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of a capsule.
number InRadius
The radius of a capsule.
number InHalfHeight
The height of a capsule.
Vector3 InDirection
A vector representing the capsule's movement direction; its length (size) also determines the detectable distance.
string ProfileName
The name of the collision profile used for collision detection. The detection targets are determined by the collision response settings of the profile.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
Return
RaycastResult
A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs.
Code Samples
DrawRay
This method displays a ray of a specified color on the screen based on a given origin and direction for visual representation.
This is mainly used for debugging and is helpful for visually identifying the direction and destination of a Raycast.
Parameters
Vector3 InOrigin
The starting point from which the ray is cast.
Vector3 InDirection
This vector defines the direction of the ray. The length (magnitude) of this vector also determines how far the ray can detect Objects.
Color3 InColor
The color of the ray.
number InThickness
The width of the ray.
number InLifeTime
The duration (in seconds) that the ray persists in the world.
Return
void
Code Samples
GetPartBoundsInBox
Searches for and returns an array of parts that overlap with a box-shaped region defined by a given Center and Size. Use OverlapParams to fine-tune filtering conditions and detection scope.
Parameters
CFrame InCenter
The center coordinate of the region to be detected.
Vector3 InSize
The width, height, and depth of the box-shaped detection region.
OverlapParams InOverlapParams
A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
Array
An array of the objects detected within the box-shaped region.
Code Samples
GetPartBoundsInBoxByChannel
Finds parts overlapping a box-shaped region defined by a given Center and Size, filtered by the specified collision channel (TraceChannel), and returns them as an array. It works like GetPartBoundsInBox, but performs collision detection based on a collision channel.
Parameters
CFrame InCenter
The center coordinate of the region to detect.
Vector3 InSize
The width, length, and height of the box-shaped detection range.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of objects detected within the box-shaped region.
Code Samples
GetPartBoundsInBoxByChannelName
Finds parts overlapping a box-shaped region defined by a given Center and Size, filtered by the name of the specified collision channel (ChannelDisplayName), and returns them as an array. It works like GetPartBoundsInBoxByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls GetPartBoundsInBoxByChannel; if no channel matching the given name is found, it does not perform detection.
Parameters
CFrame InCenter
The center coordinate of the region to detect.
Vector3 InSize
The width, length, and height of the box-shaped detection range.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of objects detected within the box-shaped region. Returns an empty array if no collision channel matching the given name is found.
Code Samples
GetPartBoundsInSphere
Searches for and returns an array of parts that overlap with a sphere-shaped region defined by a given Center and Radius. It is useful for proximity check or Area-of-Effect detection.
Parameters
CFrame InCenter
The center coordinate of the sphere-shaped region to be detected.
number InRadius
The radius of a sphere.
OverlapParams InOverlapParams
A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
Array
An array of the objects detected within the sphere-shaped region.
Code Samples
GetPartBoundsInSphereByChannel
Finds parts overlapping a sphere-shaped region defined by a given Center and Radius, filtered by the specified collision channel (TraceChannel), and returns them as an array. It works like GetPartBoundsInSphere, but performs collision detection based on a collision channel.
Parameters
CFrame InCenter
The center coordinate of the sphere-shaped region to detect.
number InRadius
The radius of the sphere.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of objects detected within the sphere-shaped region.
Code Samples
GetPartBoundsInSphereByChannelName
Finds parts overlapping a sphere-shaped region defined by a given Center and Radius, filtered by the name of the specified collision channel (ChannelDisplayName), and returns them as an array. It works like GetPartBoundsInSphereByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls GetPartBoundsInSphereByChannel; if no channel matching the given name is found, it does not perform detection.
Parameters
CFrame InCenter
The center coordinate of the sphere-shaped region to detect.
number InRadius
The radius of the sphere.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of objects detected within the sphere-shaped region. Returns an empty array if no collision channel matching the given name is found.
Code Samples
GetPartsInPart
Searches for and returns an array of all parts that overlap (collide) with a specified BasePart. Use OverlapParams to fine-tune filtering conditions, such as including or excluding specific objects.
Parameters
BasePart InBasePart
The part used as the reference for collision detection.
OverlapParams InOverlapParams
A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
Array
An array of the objects detected within the part region.
Code Samples
PredictProjectilePathByChannel
Calculates and returns the predicted trajectory of a projectile, using the specified collision channel (InTraceChannel) for collision detection. It works like PredictProjectilePathByObject, but performs collision detection based on a collision channel.
Parameters
Enum.CollisionChannel InTraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
PredictProjectilePathParams PredictParams
An object containing the parameters required for trajectory prediction, such as the projectile's starting position, velocity, and gravity.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
PredictProjectilePathResult
A result object containing information about the first object the projectile collided with along its trajectory.
Code Samples
PredictProjectilePathByChannelName
Calculates and returns the predicted trajectory of a projectile, using the name of the specified collision channel (ChannelDisplayName) for collision detection. It works like PredictProjectilePathByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls PredictProjectilePathByChannel; if no channel matching the given name is found, it does not perform trajectory prediction.
Parameters
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, trajectory prediction is not performed.
PredictProjectilePathParams PredictParams
An object containing the parameters required for trajectory prediction, such as the projectile's starting position, velocity, and gravity.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
PredictProjectilePathResult
A result object containing information about the first object the projectile collided with along its trajectory. Returns an empty result object if no collision channel matching the given name is found.
Code Samples
PredictProjectilePathByObject
Calculates and returns the predicted trajectory of a projectile based on object query parameters.
Parameters
PredictProjectilePathParams PredictParams
An object containing parameters required for trajectory prediction, including the projectile's starting position, velocity, and gravity.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
PredictProjectilePathResult
A result object containing information about the first object the projectile collided with along its trajectory.
Code Samples
Raycast
Casts an invisible ray based on a given origin and direction to detect objects along its path, and returns the result as a RaycastResult object. You can use a RaycastParams object to define specific targets or conditions for detection if needed. If omitted, the default settings apply, and all parts become detectable.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray’s direction; its length (size) also determines the detectable distance.
RaycastParams InRaycastParams
A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
RaycastResult
A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.
Code Samples
RaycastMulti
Casts a ray based on a given origin and direction to detect all objects along its path, and returns the results as an array. Unlike Raycast, which returns only the first collision, it returns all collision results along the ray's path. Useful for penetration effects and multiple target detection.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray’s direction; its length (size) also determines the detectable distance.
RaycastParams InRaycastParams
A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
Array
An array of all RaycastResult objects detected along a ray’s path.
Code Samples
RaycastMultiByChannel
Casts a ray based on a given origin and direction, detects all objects along its path filtered by the specified collision channel (TraceChannel), and returns the results as an array. It works like RaycastMulti, but performs collision detection based on a collision channel.
Parameters
Vector3 InOrigin
The starting point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of all RaycastResult objects detected along the ray's path.
Code Samples
RaycastMultiByChannelName
Casts a ray based on a given origin and direction, detects all objects along its path filtered by the name of the specified collision channel (ChannelDisplayName), and returns the results as an array. It works like RaycastMultiByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls RaycastMultiByChannel; if no channel matching the given name is found, it does not perform detection.
Parameters
Vector3 InOrigin
The starting point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
Array
An array of all RaycastResult objects detected along the ray's path. Returns an empty array if no collision channel matching the given name is found.
Code Samples
RaycastMultiByObject
Casts a ray based on object query parameters, detects all objects along its path, and returns the results as an array. It works like RaycastMulti, but performs collision detection based on object type.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray’s direction; its length (size) also determines the detectable distance.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
Array
An array of all RaycastResult objects detected along a ray’s path.
Code Samples
RaycastMultiByProfile
Casts a ray based on the specified collision profile (ProfileName), detects all objects along its path, and returns the results as an array. It works like RaycastMulti, but performs collision detection based on a collision profile.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
string ProfileName
The name of the collision profile used for collision detection. The detection targets are determined by the collision response settings of the profile.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
Return
Array
An array of all RaycastResult objects detected along a ray's path.
Code Samples
RaycastSingleByChannel
Casts a ray based on a given origin and direction, detects the first object hit along its path filtered by the specified collision channel (TraceChannel), and returns the result as a RaycastResult object. It works like Raycast, but performs collision detection based on a collision channel.
Parameters
Vector3 InOrigin
The starting point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the ray collided with. Returns nil if no collision occurs.
Code Samples
RaycastSingleByChannelName
Casts a ray based on a given origin and direction, detects the first object hit along its path filtered by the name of the specified collision channel (ChannelDisplayName), and returns the result as a RaycastResult object. It works like RaycastSingleByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls RaycastSingleByChannel; if no channel matching the given name is found, it does not perform collision detection.
Parameters
Vector3 InOrigin
The starting point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the ray collided with. Returns nil if no collision occurs or if no collision channel matching the given name is found.
Code Samples
RaycastSingleByObject
Casts a ray based on object query parameters, detects the first colliding object along its path, and returns a RaycastResult object. It works like Raycast, but performs collision detection based on object type.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray’s direction; its length (size) also determines the detectable distance.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
RaycastResult
A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.
Code Samples
RaycastSingleByProfile
Casts a ray based on the specified collision profile (ProfileName), detects the first colliding object along its path, and returns a RaycastResult object. It works like Raycast, but performs collision detection based on a collision profile.
Parameters
Vector3 InOrigin
The origin point from which the ray is cast.
Vector3 InDirection
A vector representing the ray's direction; its length (size) also determines the detectable distance.
string ProfileName
The name of the collision profile used for collision detection. The detection targets are determined by the collision response settings of the profile.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
Return
RaycastResult
A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.
Code Samples
Spherecast
Moves a sphere-shaped region defined by a given origin and radius into a specified direction, detects any objects along its path, and returns the result as a RaycastResult object. It works like Raycast, but can detect a broader area of Objects as it detects collision in a sphere shape instead of a ray shape. Useful for melee weapon detections and wide-area collision detections.
Parameters
Vector3 InOrigin
The origin point of a sphere.
number InRadius
The radius of a sphere.
Vector3 InDirection
A vector representing the sphere’s movement direction; its length (size) also determines the detectable distance.
RaycastParams InRaycastParams
A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.
Return
RaycastResult
A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs.
Code Samples
SpherecastSingleByChannel
Moves a sphere-shaped region defined by a given position (CFrame) and Radius into a specified Direction, detects any objects along its path based on the specified collision channel (TraceChannel), and returns the result as a RaycastResult object. It works like Spherecast, but performs collision detection based on a collision channel.
Parameters
CFrame InCFrame
The coordinate frame representing the sphere's initial position and rotation.
number InRadius
The radius of the sphere.
Vector3 InDirection
A vector representing the sphere's movement direction; its length (size) also determines the detectable distance.
Enum.CollisionChannel TraceChannel
The collision channel used for collision detection. Only objects whose response to this channel is set to Block or Overlap become detection targets.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs.
Code Samples
SpherecastSingleByChannelName
Moves a sphere-shaped region defined by a given position (CFrame) and Radius into a specified Direction, detects any objects along its path based on the name of the specified collision channel (ChannelDisplayName), and returns the result as a RaycastResult object. It works like SpherecastSingleByChannel, but allows specifying the collision channel by name (string) instead of Enum.CollisionChannel. Internally, it converts the name to a collision channel and then calls SpherecastSingleByChannel; if no channel matching the given name is found, it does not perform collision detection.
Parameters
CFrame InCFrame
The coordinate frame representing the sphere's initial position and rotation.
number InRadius
The radius of the sphere.
Vector3 InDirection
A vector representing the sphere's movement direction; its length (size) also determines the detectable distance.
string ChannelDisplayName
The name of the collision channel used for collision detection. The search prioritizes channel names registered in the collision profile; if no channel with the given name is found, detection is not performed.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored. If not specified, the default settings apply.
CollisionResponseParams InResponseParams
An object specifying the response behavior for each collision channel. If not specified, the default response settings apply.
Return
RaycastResult
A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs or if no collision channel matching the given name is found.
Code Samples
SpherecastSingleByObject
Moves a sphere-shaped region defined by a given position (CFrame) and Radius into a specified Direction, detects any objects along its path based on object query parameters, and returns the result as a RaycastResult object. It works like Spherecast, but performs collision detection based on object type.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of a sphere.
number InRadius
The radius of a sphere.
Vector3 InDirection
A vector representing the sphere's movement direction; its length (size) also determines the detectable distance.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
CollisionObjectQueryParams InObjectParams
An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.
Return
RaycastResult
A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs.
Code Samples
SpherecastSingleByProfile
Moves a sphere-shaped region defined by a given position (CFrame) and Radius into a specified Direction, detects any objects along its path based on the specified collision profile (ProfileName), and returns the result as a RaycastResult object. It works like Spherecast, but performs collision detection based on a collision profile.
Parameters
CFrame InCFrame
The coordinate frame representing the initial position and rotation of a sphere.
number InRadius
The radius of a sphere.
Vector3 InDirection
A vector representing the sphere's movement direction; its length (size) also determines the detectable distance.
string ProfileName
The name of the collision profile used for collision detection. The detection targets are determined by the collision response settings of the profile.
CollisionQueryParams InQueryParams
An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.
Return
RaycastResult
A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs.
Code Samples
Events
Last updated