shooting ray at right direction

Hi,

i want to shoot a ray in the direction my 2d player (with 3d collider) is facing
So the facing of the sprite changes x=1 / x=-1 if i press left/right

i want to say if Scale X = 1 then shoot ray left
and if Scale X = -1 then shoot the ray right

i can shoot the ray but can’t handle the facing.

    private void Update()
    {

        if (transform.localScale.x= 1)  //<here i don't know how to type it correct. The rest seems to work.
            {
        Ray ray = new Ray (transform.position, -transform.right);
        Debug.DrawRay (ray.origin, ray.direction, Color.red);
            }
        else

        {
            Ray ray = new Ray (transform.position, transform.right);
            Debug.DrawRay (ray.origin, ray.direction, Color.blue);
        }

    }
}
if (transform.localScale.x == 1)// == sign checks if one value is equal to the other. = sign assigns value on the right of it to variable on its left.
        {
            Ray ray = new Ray(transform.position, -transform.right);
            Debug.DrawRay(ray.origin, ray.direction, Color.red);
        }
        else

        {
            Ray ray = new Ray(transform.position, transform.right);
            Debug.DrawRay(ray.origin, ray.direction, Color.blue);
        }