Class · inherits Model
WorldRoot
Base class for handling physics simulation and 3D spatial queries.
About WorldRoot
This base class provides an API for any instance intended for handling 3D
spatial queries and simulation, such as Workspace and
WorldModel.
Methods 19
ArePartsTouchingOthers
(partList: Instances, overlapIgnored: float = 0.000199999995) → booleanReturns true if any of the givenBasePartare touching any other parts.ArePartsTouchingOthers returns true if at least one of the given
BasePartare touching any other parts. Two parts are considered "touching" if they are within the distance threshold,overlapIgnored.If no parts are provided, false is returned.
Blockcast
(cframe: CFrame, size: Vector3, direction: Vector3, params: RaycastParams = RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → RaycastResult?Casts a block shape in a given direction and returns aRaycastResultif the shape hits aBasePartorTerraincell.Casts a block shape in a given direction and returns the first collision with a
BasePartorTerraincell. This is analogous to howWorldRoot.Raycastcasts a linear ray in a direction to find a collision, but it uses a 3D shape instead of a ray.Unlike
WorldRoot.GetPartsInPart, this method does not detectBasePartsthat initially intersect the shape.If a hit is detected, a
RaycastResultis returned containing the hit information. TheDistanceproperty represents the distance the shape has to travel to find a hit, and thePositionproperty represents the intersection point that causes the hit.This method throws an error if it is passed invalid
CFrame, size, or direction inputs.BulkMoveTo
(partList: Instances, cframeList: Array, eventMode: BulkMoveMode = FireAllEvents) → ()Moves an array ofBasePartsto an array ofCFrames.This function moves an array of
BasePartsto an array ofCFrameswithout necessarily firing the default propertyChangedevents. This provides a very fast way to move large numbers of parts, as you don't have to pay the cost of separate property sets for each individual part.Both
partListandcframeListare sequential arrays (Luau tables with integer indices starting at 1), not dictionaries. Each part at indexiinpartListis moved to theCFrameat indexiincframeList. The arrays must contain the same number of entries.local Workspace = game:GetService("Workspace") local partList = { Workspace.Part1, Workspace.Part2 } local cframeList = { CFrame.new(0, 5, 0), CFrame.new(10, 5, 0) } Workspace:BulkMoveTo(partList, cframeList, Enum.BulkMoveMode.FireCFrameChanged)The third argument allows you to further optimize the movement operation. By default, the
Changedevent of each part fires forPosition,Orientation, andCFrame. However, if you specifyFireCFrameChangedas the third argument, only theChangedevent for theCFrameproperty will fire.Note that you should only use this function if you're sure that part movement is a bottleneck in your code. Simply setting the
CFrameproperty of individual parts and welded models is fast enough in the majority of cases.CollisionGroupsAreCollidable
(name1: string, name2: string) → booleanReturns whether the two groups will collide in this world.Returns whether the two specified collision groups will collide in this world. This method will also return
trueif either of the groups are unregistered in this world, as the default collision mask collides with all groups.CollisionGroupSetCollidable
(name1: string, name2: string, collidable: boolean) → ()Sets the collision status between two groups in this world.Sets the collision status between two groups in this world. This method will throw an error if either of the groups is unregistered in this world, so it's recommended that you confirm each group's registration through
WorldRoot.IsCollisionGroupRegisteredbefore making this call.GetMaxCollisionGroups
() → intReturns the maximum number of collision groups in this world.Returns the maximum number of collision groups the engine supports per world. This value is currently 32.
GetPartBoundsInBox
(cframe: CFrame, size: Vector3, overlapParams: OverlapParams = OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → List<BasePart>Returns an array of parts whose bounding boxes overlap a given box.WorldRoot.GetPartBoundsInBoxreturns an array of parts whose bounding boxes overlap a box whose volume is described using the given center (CFrame) and size (Vector3).As emphasized, this spatial query method efficiently considers the volume of parts' bounding boxes rather than their actual occupied volume. This may be important when considering cylinders, spheres, unions, and
MeshPartswhich have non-block shapes. For cases where accuracy especially matters, useWorldRoot.GetPartsInPartinstead, or further filter the results of this method yourself.This method uses a
OverlapParamsobject to describe reusable portions of the spatial query, such as an inclusion or exclusion list, the maximum number of parts to query, what collision group to use, and whether the query favors an intersected part'sBasePart.CanCollidevalue over itsBasePart.CanQueryvalue.GetPartBoundsInRadius
(position: Vector3, radius: float, overlapParams: OverlapParams = OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → List<BasePart>Returns an array of parts whose bounding boxes overlap a given sphere.WorldRoot.GetPartBoundsInRadiusreturns an array of parts whose bounding boxes overlap a sphere whose volume is described using the given center (Vector3) and radius (number).As emphasized, this spatial query method efficiently considers the volume of parts' bounding boxes rather than their actual occupied volume. This may be important when considering cylinders, spheres, unions, and
MeshPartswhich have non-block shapes. For cases where accuracy especially matters, useWorldRoot.GetPartsInPartinstead, or further filter the results of this method yourself.This method uses a
OverlapParamsobject to describe reusable portions of the spatial query, such as an inclusion or exclusion list, the maximum number of parts to query, what collision group to use, and whether the query favors an intersected part'sBasePart.CanCollidevalue over itsBasePart.CanQueryvalue.GetPartsInPart
(part: BasePart, overlapParams: OverlapParams = OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → List<BasePart>Returns an array of parts whose occupied space is shared with the given part.WorldRoot.GetPartsInPartreturns an array of parts whose occupied space is shared with the given part (which must exist in the sameWorldRootas the parts to be queried). This method can be used in place ofBasePart.GetTouchingPartsand is generally a better choice.As noted, this spatial query method considers the exact volume occupied by the given part using a full geometric collision check. As an example, a concave/hollow part won't match queried parts within it unless they actually overlap/touch such a part. For simpler volumes, consider using
WorldRoot.GetPartBoundsInBoxorWorldRoot.GetPartBoundsInRadius, as they are less accurate but perform more efficiently.This method uses a
OverlapParamsobject to describe reusable portions of the spatial query, such as an inclusion or exclusion list, the maximum number of parts to query, what collision group to use, and whether the query favors an intersected part'sBasePart.CanCollidevalue over itsBasePart.CanQueryvalue.GetRegisteredCollisionGroups
() → ArrayReturns a table with info on all of this world's collision groups.Returns a table with info on all of this world's collision groups. Each value in the returned table is itself a table and containing two members:
IKMoveTo
(part: BasePart, target: CFrame, translateStiffness: float = 0.5, rotateStiffness: float = 0.5, collisionsMode: IKCollisionsMode = OtherMechanismsAnchored) → ()PluginMoves the specified part to the specified location via inverse kinematics rather than moving it there directly, to ensure any joints, constraints, or collisions that part is participating in remain physically satisfied.This function moves the specified part to the specified location via inverse kinematics rather than moving it there directly, to ensure any joints,
constraints, or collisions that part is participating in remain physically satisfied. Currently this function is only available in Studio toplugins, as it currently conflicts with the physics of a running game.Translate stiffness is a number between 0 and 1 specifying how aggressively to match the part's position to the position part of the target CFrame. Rotate stiffness is a number between 0 and 1 specifying how aggressively to match the part's rotation to the rotation part of the target CFrame.
For example:
- If translate stiffness and rotate stiffness are both equal to 1, then the part will be moved exactly to the target CFrame regardless of what physical constraints there are on it.
- If translate stiffness and rotate stiffness are both equal to 0.5, then the part will try to move to exactly the target CFrame, but may be pushed out of the way by physical constraints on it.
- If translate stiffness and rotate stiffness are both equal to 0, then the target CFrame will be ignored and physical constraints will be solved for the object at the position where it was.
IsCollisionGroupRegistered
(name: string) → booleanChecks if a collision group is registered in this world.Checks if a collision group is registered in this world. It's recommended that you call this method before calling methods that throw errors for unregistered collision groups, such as
WorldRoot.CollisionGroupSetCollidable.Raycast
(origin: Vector3, direction: Vector3, raycastParams: RaycastParams = RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → RaycastResult?Casts a ray using an origin, direction, and optionalRaycastParams, then returns aRaycastResultif an eligible object or terrain intersects the ray.Casts a ray using an origin, direction, and optional
RaycastParams. If it finds an eligibleBasePartorTerraincell, aRaycastResultis returned containing the results of the operation. If noRaycastParamsobject is provided, the defaults are used (all parts are considered andTerrainwater is not ignored).Note that the length (magnitude) of the directional vector is important, as objects/terrain further away than its length will not be tested. If you're using a
CFrameto help create the ray components, consider usingCFrame.LookVectoras the directional vector and multiply it by the desired length as shown in the example below. The maximum length of the direction vector is 15,000 studs.This method does not use a
Rayobject, but its origin and direction components can be borrowed fromRay.OriginandRay.Direction.RegisterCollisionGroup
(name: string) → ()Registers a new collision group in this world with the given name.Registers a new collision group in this world with the given name. The name cannot be
"Default".Note that this method has a slight performance overhead based on the number of
BasePartsin the world, so it's recommended that you register all collision groups at edit time through the Studio editor and callUnregisterCollisionGroup()andRenameCollisionGroup()as infrequently as possible.RenameCollisionGroup
(from: string, to: string) → ()Renames specified collision group in this world.Renames the specified registered collision group in this world, but does not rename the
CollisionGroupproperty of parts that utilize the group. The first argument of this method is the name of the group to rename, the second argument is the new name for the group. If the specified group does not exist, this method will not do anything. The naming conventions for the new name follow the same rules as if the group was being created withRegisterCollisionGroup().This method will throw a runtime error in the following circumstances:
- Invalid or empty name provided for either argument.
- The method is called from a client.
Note that this method has a slight performance overhead based on the number of
BasePartsin the world, so it's recommended that you register all collision groups at edit time through the Studio editor and rename them as infrequently as possible.Shapecast
(part: BasePart, direction: Vector3, params: RaycastParams = RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}, cframeOverride: CFrame? = nil, sizeOverride: Vector3? = nil) → RaycastResult?Casts the shape of a givenBasePartin a direction and returns aRaycastResultif the shape hits aBasePartorTerraincell.Casts the shape of the given
BasePartin a given direction and returns the first collision with aBasePartorTerraincell. This is analogous to howWorldRoot.Raycastcasts a linear ray in a direction to find a collision, but it uses a 3D shape instead of a ray. UnlikeWorldRoot.BlockcastandWorldRoot.Spherecast, which use a simple box or sphere, this method casts the actual geometry of the provided part.Unlike
WorldRoot.GetPartsInPart, this method does not detectBasePartsthat initially intersect the shape.If a hit is detected, a
RaycastResultis returned containing the hit information. TheDistanceproperty represents the distance the shape has to travel to find a hit, and thePositionproperty represents the intersection point that causes the hit.This method throws an error if it is passed a non-existent part, an invalid direction, or a part with
Terraingeometry.Spherecast
(position: Vector3, radius: float, direction: Vector3, params: RaycastParams = RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}) → RaycastResult?Casts a spherical shape in a given direction and returns aRaycastResultif the shape hits aBasePartorTerraincell.Casts a spherical shape in a given direction and returns the first collision with a
BasePartorTerraincell. This is analogous to howWorldRoot.Raycastcasts a linear ray in a direction to find a collision, but it uses a 3D shape instead of a ray.Unlike
WorldRoot.GetPartsInPart, this method does not detectBasePartsthat initially intersect the shape.If a hit is detected, a
RaycastResultis returned containing the hit information. TheDistanceproperty represents the distance the shape has to travel to find a hit, and thePositionproperty represents the intersection point that causes the hit.This method throws an error if it is passed invalid radius or direction inputs.
StepPhysics
(dt: float, parts: Instances = {}) → ()PluginAdvances the simulation for parts in the world forward based on a specified time increment and an optional set ofBaseParts.Advances the simulation for parts in the world forward based on a specified time increment and an optional set of
BasePart. When a set of parts is specified, only these parts will be simulated and all other parts in the world will be treated as anchored. When this argument is left out, all parts in the world will be included in the simulation. The specified time increment can be any positive number, with larger values increasing the runtime of the function. Depending on the value of the time increment, the physics system may subdivide it into multiple individual steps to maintain the accuracy and stability of the simulation. Even if the function performs multiple substeps, the results of the simulation will only be seen once the function completes. To visualize the individual steps of a simulation, the function can be called once per RenderStep via theRunService.RenderSteppedevent.UnregisterCollisionGroup
(name: string) → ()Unregisters the collision group for the given name in this world.Unregisters the collision group for the given name in this world, with the following behaviors:
- If an invalid name is provided, the method will not do anything.
- If the reserved name
"Default"is provided or if the method is called from a client, it will throw an error. - If there are any parts in the collision group when it is removed, those
parts will still maintain the same collision group name. The physical
behavior of parts in a removed group is undefined, so it's recommended
to move any parts in a removed group to another group, such as the
"Default"group.
Note that this method has a slight performance overhead based on the number of
BasePartsin the world, so it's recommended that you register all collision groups at edit time through the Studio editor and call this method as infrequently as possible.
WorldRoot also has every member of Model. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.