Script cannot find specified instance.

So after much struggle i must request help. I have 3 Scripts that pertain to the enemy and player

Player, Creature (the variables script for player and enemy) and enemy

i have an attacking system that depends on finding the gameobject the script is attached to.

the script creature is suppose to call

player.GetComponent().playerisattacking();

and
enemy.GetComponent().enemyisattacking();

even after setting the gameobjects to public and manually setting them (its intended to be multiplayer so manually setting them is not a permanent fix) i still get object reference not set to instance of an object

the gameobject in player named player and the game object named enemy is suppose to be called in creature by referring to the set variables in both of the corresponding scripts anyways heres the 3 scripts.

and yes i double checked all the gameobjects the scripts and components are set correctly

screen shot just incase you want to see

Creature script

using UnityEngine;
using System.Collections;

public abstract class Creature : MonoBehaviour
{  Enemy enemy;
  Player1 player;
  public float maxhealth;
  public bool startattackrole;
  private int d8;
  public int attackstat;
  public int waittime;
  public int idletime;
  public string name;
  public float health;
  public int damage;
  public float range;
  public bool enemyattack;
  public bool Playerattack;
  public int playerattackroleoutput;
  public int enemyattackroleoutput;
  public bool playergo;
  public bool enemygo;
  //1 attack per seond
  public float attackSpeed = 2f;
  public Animator attackanimaton;

  public void GetHit(int playerDamage)
  {
  health = health - playerDamage;

  }

  protected abstract IEnumerator Autoaction();


  void attackisgo()
  {
  if (playerattackroleoutput > enemyattackroleoutput)
  {
  player.GetComponent<Player1>().playerisattacking();
  }

  if (enemyattackroleoutput > playerattackroleoutput)
  {
  enemy.GetComponent<Enemy>().enemyisattacking();
  }
  }

  public void attackrolego()
  {
  Debug.Log("Attackrolego has activated");
  d8output();
  enemyattackroleoutputgo();
  d8output();
  playerattackroleoutputgo();
  attackisgo();

  }

  void enemyattackroleoutputgo()
  {

  enemyattackroleoutput = d8 + attackstat;

  }

  void playerattackroleoutputgo()
  {
  playerattackroleoutput = d8 + attackstat;

  }
  void d8output()
  {
  d8 = Random.Range(1, 8);
  }

  // Use this for initialization
  void Awake() {
  attackanimaton = GetComponent<Animator>();
  Playerattack = false;
  enemyattack = false;
  d8 = Random.Range(1, 8);
  playergo = false;
  enemygo = false;
  startattackrole = false;
  
  }

  

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

  }
}

Player script

using UnityEngine;
using System.Collections;
using System;

public class Player1 : Creature
{
  bool activeattack;
  public static bool isAttacking;
  public static bool playerattack;
  public float fpstargetdistance;
  public Transform fpstarget;
  GameObject player;
  void targetingsystem()
  {
  fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
  }

  // Use this for initialization
  void Awake()
  {
  health = maxhealth;
  Vector3 player = transform.position;
  isAttacking = false;

  }

  // Update is called once per frame
  void Update()
  {
  targetingsystem();
  attacktrue();
  }

  protected override IEnumerator Autoaction()
  {
  if (playerattack == true && (fpstargetdistance < range))
  {
  Debug.Log("player is attacking");
  playergo = false;
  enemyattack = false;
  attackanimaton.SetBool("isAttacking", true);
  attackanimaton.SetFloat("Attack", 9.0f);
  fpstarget.GetComponent<Enemy>().GetHit(damage);
  yield return new WaitForSecondsRealtime(idletime);
  attackanimaton.SetFloat("Attack", 4.0f);
  Debug.Log("player waiting");
  yield return new WaitForSecondsRealtime(waittime);
  enemyattack = true;
  


  }
  }

  public  void playerisattacking()
  {
  if (playergo == true)
  Debug.Log("player is attacking frist");
  playerattack = true;
  StartCoroutine(Autoaction());
  }

  void attacktrue()
  {
  if (Input.GetMouseButtonDown(1))
  {
  attackrolego();
  }
  }
}

Enemy script

using UnityEngine;
using System.Collections;

public class Enemy : Creature {
  NavMeshAgent navAgent;
  public GameObject enemy;
  bool activeattack;
  public float chasingRange;
  public static bool block;
  public float chasingrange;
  public float fpstargetdistance;
  public float enemylookdistance;
  public float attackdistance;
  public float enemymovementspeed;
  public float damping;
  public Transform fpstarget;
  Rigidbody therigidbody;
  Renderer myrender;
  // Use this for initialization



  void  targetingsystem()
  {
  fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
  }
  void Awake () {
  Vector3 enemy = transform.position;
  navAgent = GetComponent<NavMeshAgent>();
  myrender = GetComponent<Renderer>();
  therigidbody = GetComponent <Rigidbody>();
   }
  
   // Update is called once per frame
   void Update () {
  targetingsystem();
  }






  protected override IEnumerator Autoaction()

  {
  if (enemyattack == true && (fpstargetdistance < range))
  {
  enemygo = false;
  Debug.Log("enemy is attacking");
  Playerattack = false;
  attackanimaton.SetBool("isAttacking", true);
  attackanimaton.SetFloat("Attack", 9.0f);
  fpstarget.GetComponent<Player1>().GetHit(damage);
  yield return new WaitForSecondsRealtime(idletime);
  attackanimaton.SetFloat("Attack", 4.0f);
  Debug.Log("waiting");
  yield return new WaitForSecondsRealtime(waittime);
  Playerattack = true;



  }

  
  }



  public void enemyisattacking()
  {
  if (enemygo == true)
  Debug.Log("enemy is attcking first");
  enemyattack = true;
  StartCoroutine(Autoaction());
  }

}

player is a variable of type Player1, you don’t need to get the component, either remove that, or change Player to GameObject

so i updated the scripts but i am still receiving the same error

enemy

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


public class Enemy : Creature {
    public static Enemy enemy;
    NavMeshAgent navAgent;
    bool activeattack;
    public float chasingRange;
    public static bool block;
    public float chasingrange;
    public float fpstargetdistance;
    public float enemylookdistance;
    public float attackdistance;
    public float enemymovementspeed;
    public float damping;
    public Transform fpstarget;
    Rigidbody therigidbody;
    Renderer myrender;
    // Use this for initialization



    void  targetingsystem()
    {
        fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
    }
    void Awake () {

        enemy = this;
        navAgent = GetComponent<NavMeshAgent>();
        myrender = GetComponent<Renderer>();
        therigidbody = GetComponent <Rigidbody>();
    }
 
    // Update is called once per frame
    void Update () {
        targetingsystem();
    }






    protected override IEnumerator Autoaction()

    {
            if (enemyattack == true && (fpstargetdistance < range))
            {
                    enemygo = false;
                    Debug.Log("enemy is attacking");
                    Playerattack = false;
                    attackanimaton.SetBool("isAttacking", true);
                    attackanimaton.SetFloat("Attack", 9.0f);
                    fpstarget.GetComponent<Player1>().GetHit(damage);
                    yield return new WaitForSecondsRealtime(idletime);
                    attackanimaton.SetFloat("Attack", 4.0f);
                    Debug.Log("waiting");
                    yield return new WaitForSecondsRealtime(waittime);
                    Playerattack = true;



                }

     
    }



    public void enemyisattacking()
    {
        if (enemygo == true)
            Debug.Log("enemy is attcking first");
            enemyattack = true;
            StartCoroutine(Autoaction());
    }

}

player

public class Player1 : Creature
{
    public static Player1 player;
    bool activeattack;
    public static bool isAttacking;
    public static bool playerattack;
    public float fpstargetdistance;
    public Transform fpstarget;


    void targetingsystem()
    {
        fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
    }

    // Use this for initialization
    void Awake()
    {
        player = this;
        health = maxhealth;
        isAttacking = false;

    }

    // Update is called once per frame
    void Update()
    {
        targetingsystem();
        attacktrue();
    }

    protected override IEnumerator Autoaction()
    {
            if (playerattack == true && (fpstargetdistance < range))
            {
                Debug.Log("player is attacking");
                playergo = false;
                enemyattack = false;
                attackanimaton.SetBool("isAttacking", true);
                attackanimaton.SetFloat("Attack", 9.0f);
                fpstarget.GetComponent<Enemy>().GetHit(damage);
                yield return new WaitForSecondsRealtime(idletime);
                attackanimaton.SetFloat("Attack", 4.0f);
                Debug.Log("player waiting");
                yield return new WaitForSecondsRealtime(waittime);
                enemyattack = true;
     


        }
    }

    public  void playerisattacking()
    {
        if (playergo == true)
            Debug.Log("player is attacking frist");
            playerattack = true;
            StartCoroutine(Autoaction());
    }

    void attacktrue()
    {
        if (Input.GetMouseButtonDown(1))
        {
            attackrolego();
        }
    }
}

Creature

using UnityEngine;
using UnityEngine;
using System.Collections;


public abstract class Creature : MonoBehaviour
{   Enemy enemy;
    Player1 player;
    public float maxhealth;
    public bool startattackrole;
    private int d8;
    public int attackstat;
    public int waittime;
    public int idletime;
    public string name;
    public float health;
    public int damage;
    public float range;
    public bool enemyattack;
    public bool Playerattack;
    public int playerattackroleoutput;
    public int enemyattackroleoutput;
    public bool playergo;
    public bool enemygo;
    //1 attack per seond
    public float attackSpeed = 2f;
    public Animator attackanimaton;

    public void GetHit(int playerDamage)
    {
        health = health - playerDamage;

    }

    protected abstract IEnumerator Autoaction();


    void attackisgo()
    {
        if (playerattackroleoutput > enemyattackroleoutput)
        {
            player.playerisattacking();
        }

        if (enemyattackroleoutput > playerattackroleoutput)
        {
            enemy.enemyisattacking();
        }
    }

    public void attackrolego()
    {
            Debug.Log("Attackrolego has activated");
        d8output();
        enemyattackroleoutputgo();
        d8output();
        playerattackroleoutputgo();
        attackisgo();

    }

    void enemyattackroleoutputgo()
    {

        enemyattackroleoutput = d8 + attackstat;

    }

    void playerattackroleoutputgo()
    {
        playerattackroleoutput = d8 + attackstat;

    }
    void d8output()
    {
        d8 = Random.Range(1, 8);
    }

    // Use this for initialization
    void Awake() {
        attackanimaton = GetComponent<Animator>();
        Playerattack = false;
        enemyattack = false;
        d8 = Random.Range(1, 8);
        playergo = false;
        enemygo = false;
        startattackrole = false;
        player = Player1.player;
        enemy = Enemy.enemy;
    }

 

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

    }
}

Player1.player is never initialized, it’s a static variable, you can’t do that, get the player gameObject and use GetComponent()
same with enemy

got it the easier thing to do was just make a method in creature and share it in enemy and player

however i now have another issue the player attacks just find but for some reason creature will not call thenemisattacking from the enemy script

enemy also wont change any of the variables assigned to it by creature

using UnityEngine;
using System.Collections;
using System;

public class Player1 : Creature
{
    public static Player1 player;
    bool activeattack;
    public static bool isAttacking;
    public static bool playerattack;
    public float fpstargetdistance;
    public Transform fpstarget;

    void targetingsystem()
    {
        fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
    }

    // Use this for initialization
    void Awake()
    {
        player = this;
        health = maxhealth;

        isAttacking = false;

    }

    // Update is called once per frame
    void Update()
    {
        targetingsystem();
        attacktrue();
    }

    protected override IEnumerator Autoaction()
    {
        if (playerattack == true && (fpstargetdistance < range))
        {
            Debug.Log("player is attacking");
            attackanimaton.SetBool("isAttacking", true);
            attackanimaton.SetFloat("Attack", 9.0f);
            fpstarget.GetComponent<Enemy>().GetHit(damage);
            yield return new WaitForSecondsRealtime(idletime);
            attackanimaton.SetFloat("Attack", 4.0f);
            Debug.Log("player waiting");
            yield return new WaitForSecondsRealtime(waittime);
            attackrolego();

        }
    }

    protected override void theplayerisattacking()
    {
        if (playergo == true)
            StopCoroutine(Autoaction());
            Debug.Log("player is attacking frist");
            playerattack = true;
            StartCoroutine(Autoaction());
    }

    protected override void theenemyisattacking()
    {

    }

    void attacktrue()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (fpstargetdistance < range)
        {
            attackrolego();
        }
    }
    }
}

creature

using UnityEngine;
using System.Collections;

public abstract class Creature : MonoBehaviour
{
  Enemy enemy;
  Player1 player;
  public bool enemyisattacking;
  public float maxhealth;
  public bool startattackrole;
  private int d8;
  public int attackstat;
  public int waittime;
  public int idletime;
  public string name;
  public float health;
  public int damage;
  public float range;
  public bool enemyattack;
  public bool Playerattack;
  public int playerattackroleoutput;
  public int enemyattackroleoutput;
  public bool playergo;
  public bool enemygo;
  //1 attack per seond
  public float attackSpeed = 2f;
  public Animator attackanimaton;

  public void GetHit(int playerDamage)
  {
  health = health - playerDamage;

  }

  protected abstract IEnumerator Autoaction();
  protected abstract void theplayerisattacking();
  protected abstract void theenemyisattacking();


  void attackisgo()
  {
  if (playerattackroleoutput > enemyattackroleoutput)
  {
  playergo = true;
  theplayerisattacking();
  }

  if (enemyattackroleoutput > playerattackroleoutput)
  {
  enemygo = true;
  theenemyisattacking();

  }

  else if (enemyattackroleoutput == playerattackroleoutput)
  {
  attackrolego();
  }
  }

  public void attackrolego()
  {

  enemygo = false;
  playergo = false;
  Debug.Log("Attackrolego has activated");
  d8output();
  enemyattackroleoutputgo();
  d8output();
  playerattackroleoutputgo();
  attackisgo();

  }

  void enemyattackroleoutputgo()
  {

  enemyattackroleoutput = d8 + attackstat;

  }

  void playerattackroleoutputgo()
  {
  playerattackroleoutput = d8 + attackstat;

  }
  void d8output()
  {
  d8 = Random.Range(1, 8);
  }

  // Use this for initialization
  void Awake()
  {
  enemyisattacking = true;
  enemy = Enemy.enemy;
  attackanimaton = GetComponent<Animator>();
  Playerattack = false;
  enemyattack = false;
  d8 = Random.Range(1, 8);
  playergo = false;
  enemygo = false;
  startattackrole = false;

  }



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

  }
}



creature

enemy

using UnityEngine;
using System.Collections;

public class Enemy : Creature
{
  NavMeshAgent navAgent;
  public static Enemy enemy;
  bool activeattack;
  public float chasingRange;
  public static bool block;
  public float chasingrange;
  public float fpstargetdistance;
  public float enemylookdistance;
  public float attackdistance;
  public float enemymovementspeed;
  public float damping;
  public Transform fpstarget;
  Rigidbody therigidbody;
  Renderer myrender;
  // Use this for initialization



  void targetingsystem()
  {
  fpstargetdistance = Vector3.Distance(fpstarget.position, transform.position);
  }
  void Awake()
  {

  enemy = this;

  navAgent = GetComponent<NavMeshAgent>();
  myrender = GetComponent<Renderer>();
  therigidbody = GetComponent<Rigidbody>();
  }

  // Update is called once per frame
  void Update()
  {
  targetingsystem();
  }






  protected override IEnumerator Autoaction()

  {
  if (enemyattack == true && (fpstargetdistance < range))
  {

  Debug.Log("enemy is attacking");

  attackanimaton.SetBool("isAttacking", true);
  attackanimaton.SetFloat("Attack", 9.0f);
  fpstarget.GetComponent<Player1>().GetHit(damage);
  yield return new WaitForSecondsRealtime(idletime);
  attackanimaton.SetFloat("Attack", 4.0f);
  Debug.Log("waiting");
  yield return new WaitForSecondsRealtime(waittime);
  attackrolego();
  }


  }

  protected override void theplayerisattacking()
  {

  }



  protected override void theenemyisattacking()
  {
  if (enemygo == true)
  Debug.Log("enemy is attcking first");
  enemyattack = true;
  StartCoroutine(Autoaction());
  }



}