Fire Ball Projectile going wrong way

So I am trying to get a fireball projectile to work in my game, and while it does move forward the right way when my player faced right, when the player faces left it still shoots right and pushes my player back along with it. It also has issues with it not being destroyed when it hits walls or the player, but it is destroyed when it hits enemies. I am trying to get to be destroyed when it hits anything, but pickups like coins and checkpoints.

using UnityEngine;
using System.Collections;

public class FireBallController : MonoBehaviour
{

    public float fireBallSpeed;
    public PlayerController player;

    // Use this for initialization
    void Start()
    {
        if (player.transform.localScale.x < 0)
            fireBallSpeed = -fireBallSpeed;
    }

    // Update is called once per frame
    void Update()
    {

        GetComponent<Rigidbody2D>().velocity = new Vector2(fireBallSpeed, GetComponent<Rigidbody2D>().velocity.y);

    }

    public void OnTriggerEnter2D(Collider2D other)
    {
        Destroy(gameObject);
    }
}

This is my code for it right now while I followed along a tutorial, and this is what is said to do, but it doesn’t work for me. What should I do?

Firstly, store your Rigidbody2D component in a variable to reduce the GetComponent calls and shorten your code:

Rigidbody2D rb;

void Awake(){
    rb = this.GetComponent<Rigidbody2D>();
}

void Update(){
    rb.velocity = new Vector2(fireballSpeed, rb.velocity.y);
}

For the specific collisions, you can set up custom Physics layers/matrixes for that in Edit>Project Settings>Physics (or Physics 2D, in your case). Once you create custom layers and apply them to your physics objects, you can tell them to explicitly ignore certain layers, for instance, pickups.

I’m not sure why the fireball isn’t moving away from the player, however you could set the direction on Start to face away from the player:

void Start(){
    Vector2 desRot = player.transform.position - this.transform.position;
    this.transform.localEulerAngles = desRot;
}

And then just have it move in it’s local forward axis, maybe.
Or even store the start orientation, and just have it move based on that:

  Rigidbody2D rb;
  Vector2 desRot;

    void Awake(){
        rb = this.GetComponent<Rigidbody2D>();
    }
   
   void Start(){
        desRot = player.transform.position - this.transform.position;
   }   
 
    void Update(){
        rb.velocity = (desRot * fireballSpeed);
    }

Never mind I didn’t need to do what you showed me. Although I did make a variable for the Rigidbody 2D as it does make the script shorter. The problem was that there was the variable for the PlayerController player part. I didn’t set it to find the player so it only shot out right correctly. Once I had it find who the player was it was just fine. I will take your advice though and set up separate layers for the projectile though. Thanks so much.