RaycastAll

Function of: Workspace
Returns: Table
Tags:  instance

Given a ray, returns an unordered array of all intersected parts within a max distance. Max limit of 10. Optionally ignores parts that are or are descendants of a specified dynamic

Parameters
Name Type Description
rayRayThe ray to cast with
ignoreAndDescendantsDynamicThe optional dynamic to ignore parts if equal to or children of
maxDistanceNumberThe max distance in meters the ray will travel
onlyCollidableBoolean
Example
-- prints the name of all parts when the local player clicks on something
local player = Players.LocalPlayer
local mouse = player.Mouse

mouse.LeftButtonDown:connect(function()
	local ray = Ray.new(mouse.origin.p, mouse.origin.lookvector)
	local hits = Workspace:RaycastAll(ray, player, 100)
	for _, hit in ipairs(hits) do
		print('clicked on ' .. hit.name)
	end
end)