WorldRoot

WorldRoot : Instance

Properties

Methods

Raycast

The Raycast method performs a ray-tracing operation from a given origin in a specific direction within the game world. It returns detailed information about the first object hit, if any, along the ray's path. This method is essential for physics interactions, line-of-sight calculations, and gameplay mechanics that rely on precise spatial queries.

Parameters

Vector3 InOrigin

Vector3 InDirection

RaycastParams InRaycastParams

Return

RaycastResult

Code Samples

local Workspace = game:GetService("Workspace")

local Origin = Vector3.new(0, 50, 0)
local Direction = Vector3.new(0, 0, -3000)

local RaycastParams = RaycastParams.new()
RaycastParams.FilterType = Enum.RaycastFilterType.Exclude 
RaycastParams.FilterDescendantsInstances = 
{ 
    Workspace.Part
}

local Result = Workspace:Raycast(Origin, Direction, RaycastParams)
if Result then
    print("Result Position : ", Result.Position)
    print("Result Name : ", Result.Instance.Name)
else
    print("Result nil")
end

GetPartBoundsInBox

GetPartBoundsInBox computes the parts intersecting or within a specified box area, centered at a given point and with defined size. This method is particularly useful for detecting objects in a specified region, implementing area-of-effect mechanics, and determining spatial relationships between items within a predefined boundary.

Parameters

CFrame InCenter

Vector3 InSize

OverlapParams InOverlapParams

Return

array

Code Samples

local Center = Vector3.new(0, 50, 0)
local Size = Vector3.new(1000, 1000, 1000)
local Cframe = CFrame.new(Center)
local PartsInBox = workspace:GetPartBoundsInBox(Cframe, Size)

for _, obj in ipairs(PartsInBox) do
    print(obj.Name)
end

Events

Last updated