NullReferenceException UnityEngine.Component.GetComponent[NetworkIdentity] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ComponentBindings.gen.cs:48)

Problem with calling a function from other scripts, Thanks.

Script A:

Script B Name = new Script B();


            if (Physics.Raycast(ray, out hitInfo, weaponRange, mask))
            {

                
                Instantiate(impactEffect, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
                
                if (hitInfo.collider.tag == "Player")
                {

                    //other.CmdPlayerShot(hitInfo.collider.name);
                    Name.CmdPlayerShot(hitInfo.collider.name);
                    
                    
                    //Destroy(hitInfo.transform.gameObject);
                    return;
                }

Script B:

   [Command]
     public void CmdPlayerShot(string _playerID)
    {
        Debug.Log(_playerID + "has been shot");
    }
}

attach network identity to the gameobject