-- This function casts a ray with a whitelist.

local function CastWithWhitelist(origin, direction, whitelist, ignoreWater)
	if not whitelist or typeof(whitelist) ~= "table" then
		-- This array is faulty.
		error("Call in CastWhitelist failed! Whitelist table is either nil, or is not actually a table.", 0)
	end
	local castRay = Ray.new(origin, direction)
	-- Now here's something bizarre: FindPartOnRay and FindPartOnRayWithIgnoreList have a "terrainCellsAreCubes" boolean before ignoreWater. FindPartOnRayWithWhitelist, on the other hand, does not!
	return Workspace:FindPartOnRayWithWhitelist(castRay, whitelist, ignoreWater)
end
