Make Raycast ignore anything that "Isn't" my player(Solved)

kind of a question in reverse but here goes.

I can get my enemy to track and fire at my player using a raycast and Tag combination.

if(Physics.Raycast(shootingRay, out hit, attackDistance))
		{
			if(hit.collider.tag == "Player")
			{
				InvaderFireWeapon();
			}
		}

But… if I have an object between my enemy and the player it still fires as the raycast just goes through the obstruction?

Or to put it another way how do I make it so only a direct hit by the raycast will result in an attack

???

You need to yous the layermask:

public LayerMask layerMasks;

if (Physics.Raycast(shootingRay, out hit, attackDistance, layerMasks))