I have no idea why my ray is detecting air or I think its the ray and the region3...

This is the script:

local function Map(object, length, width)
	for L = -length, length do
		for W = -width, width do
			local ray = Ray.new(plr.Character.PrimaryPart.Position + Vector3.new(L, 800, W), game.ReplicatedStorage.Down.Orientation * 5000)
			local part, hitpos = workspace:FindPartOnRay(ray, plr.Character)
			
			local cell = Region3.new(hitpos + Vector3.new(-0.5, -0.5, -0.5), hitpos - Vector3.new(-0.5, -0.5, -0.5))
			local res = 4
			cell = cell:ExpandToGrid(res)
			local mat, occ = workspace.Terrain:ReadVoxels(cell, 4)
			local color
			local size = mat.Size
			for x = 1, size.X do
				for y = 1, size.Y do
					for z = 1, size.Z do
				                local mat = mat[x][y][z]
						print(mat)
						if mat == Enum.Material.Grass then
							color = workspace.Terrain:GetMaterialColor(mat)
							
							elseif mat == Enum.CellMaterial.Grass then
							color = workspace.Terrain:GetMaterialColor(mat)
						end
					end
				end
			end
			local frame = Instance.new("Frame", MMenu.M.view)
			
			frame.Size = UDim2.new(0, 1, 0, 1)
			if color ~= nil then
				
				frame.BackgroundColor3 = color
			end
			frame.BorderSizePixel = 0
			frame.ZIndex = hitpos.Y
			frame.Position = UDim2.new(0.5, L , 0.5, W - plr.Character.PrimaryPart.position.Z)
			
			print(hitpos)

			RunService.RenderStepped:Wait()

			end
		end
		
		Map(plr, 100, 100)

This is the output:

Enum.Material.Air
-450102.25, 450846.719, -48.8493805