Impact

An Impact object can be returned when casting a ray. (see Camera.CastRay, Player.CastRay, PointerEvent.CastRay)

Properties

Block Block read-only

Block touched by the ray. Not nil if the Impact represents a Block.

local impact = Player:CastRay()
print(impact.Block)	-- prints hit block's id
number Distance read-only

Distance to impact when casting a ray. (see Camera.CastRay, Player.CastRay, PointerEvent.CastRay)

Not nil if the Impact represents a Block.

Indicates what block face has been touched.

Object touched by the ray.

Pointer.Down = function(event)
  local impact = event:CastRay()
  print(impact.Object) -- can be nil if no Object has been touched
end

Player touched by the ray.

Pointer.Down = function(event)
  local impact = event:CastRay()
  print(impact.Player) -- can be nil if no Player has been touched
end

Shape touched by the ray. Not nil if the Impact represents a Shape.