Skip to content

QueryOptions

Type

QueryOptions filters colliders tested by Physics.Raycast, Physics.OverlapSphere, Physics.OverlapBox, and Physics.Spherecast. Each entity in Exclude or Include matches itself and its descendants; if an entity matches both, Exclude wins.

Example

-- Server script in a part.
self.Name = "Crate"
self.Position = Vector3.new(0, 5, 0)
task.wait()

local origin = Vector3.new(0, 5, 10)
local aim = Vector3.new(0, 0, -1)
local hit = Physics.Raycast(origin, aim, 20, { Include = { self } })
local skipped = Physics.Raycast(origin, aim, 20, { Exclude = { self } })
print(hit and hit.Entity and hit.Entity.Name, skipped) -- prints Crate  nil

Exclude

Field
Exclude: { Entity }?

Exclude lists entities (and their descendants) to skip.

Default nil

Include

Field
Include: { Entity }?

Include restricts the query to the listed entities and their descendants; {} hits nothing.

Default nil

CollisionGroup

Field
CollisionGroup: string?

CollisionGroup names the registered collision group for the query, which hits only colliders whose group collides with that group, or nil to test every group.

Default nil

AtTick

Field
AtTick: number?

AtTick rewinds character hitboxes on a server Raycast to a past server tick (up to 64 ticks back). Other colliders and other query functions ignore AtTick. A client Raycast ignores AtTick, tests the poses that client draws, and prints a warning once per run.

Default nil