Why am I getting a null reference error?

PlayerHitNetworkScript phns = yourPlayer.GetComponent();

Also I use to get an error from this but my game would still run, but now I’m getting the same error and the game pauses.

From the information you’ve provided, it’s safe to assume that your ‘yourPlayer’ variable is null. It’s always a good idea to assume GetComponent returns null and deal with it then, something like —

yourPlayer = GameObject.FindGameObjectWithTag("myPlayer");
if(yourPlayer != null) {
    // ...
else {
    Debug.LogError("Could not find 'myPlayer'");

Double check your player and tags.