i want to write a script wich spawns a bullet which goes left or right dependig on the players rotation

I wrote a script called " hm " to spawn anything when I click on “W” . this script is the script of a bullet which goes right or left depending on the player’s rotation . " cc.f " is 1 if the player iis facing right and -1 if he’s facing left . however, I get the same error " Null reference Exception: Object reference not set to an instance of an object". Can someone please help me ?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class fire : MonoBehaviour {
public float t,speed;
private Rigidbody2D myRB;
public hm cc;
// Use this for initialization
void Start () {
myRB=GetComponent();

}

// Update is called once per frame
void Update () {
	t = cc.f; 

	myRB.velocity = new Vector2 (t*speed, myRB.velocity.y);

}

}

You never initialized your “hm” script.

EDIT: Also I missed that you didn’t assign a return type for GetComponent.

you need to set myRB to an instance of a Rigidbody2D

 myRB = GetComponent();

should be

myRB = gameobject.GetComponent<Rigidbody2D>();