How do I raycast left and right consistently on all axes?

image – Ray casting on the Z
image – Ray casting on the X

I understand that I have been ray casting only changing the X offset which is why, but I wanted a more consistent way than also ray casting on the Z (meaning I am changing x,y,z of a vector3), since it isn’t the pattern I’m trying to achieve and also a 3 way nested loop is WAY too many rays to be casting.

Looking for possible solutions. Currently I have this:

local ray = Camera:ScreenPointToRay(x,y)
		
		for y2 = 30, -30, -5 do

			for x2 = -30, 30, 5 do

				if Mouse.Hit then
					
					Scan(ray.Origin,ray.Direction * MaxDist + Vector3.new(x2,y2,0),Color3.fromRGB(255,255,255))
					
				end
				
			end

			task.wait()

		end

Thanks in advance.

What exactly are you trying to achieve? im confused.

Trying to have the second image shown but make it work no matter the direction they are facing (currently it just offsets the x and y with no rotation in it)