how to destroy all GameObjects ray went through

what I’m trying to do is to destroy all objects ray went through them in a range of 6m and not just 1 object (first).

I know I should use RaycastHit

but this gives basic idea what I’m trying to achieve

and OFC this is not on Update function so it’s only 1 go to find them all.

RaycastHit RayHits;
			if (hit[0]){
				ray = new Ray ((new Vector3(transform.position.x, transform.position.y+2, transform.position.z)),
								transform.TransformDirection(Vector3.forward));
				Debug.DrawRay ((new Vector3(transform.position.x, transform.position.y+2, transform.position.z)),
								transform.TransformDirection(Vector3.forward*6), Color.red, 5f);
				if (Physics.RaycastAll(ray, out RayHits, 6f)){
					Destroy(RayHits.collider.gameObject);
				}
			}

Something like this:

	Ray ray = new Ray ((new Vector3(transform.position.x, transform.position.y+2, transform.position.z)),
	        transform.TransformDirection(Vector3.forward));
	Debug.DrawRay ((new Vector3(transform.position.x, transform.position.y+2, transform.position.z)),
	        transform.TransformDirection(Vector3.forward*6), Color.red, 5f);
	RaycastHit[] hits = Physics.RaycastAll(ray, 6f);
	foreach (RaycastHit hit in hits) {
		Destroy(hit.collider.gameObject);
	}