Delay between shots, AI navigation not working at all

Implicitly the script is supposed to make the “shooter” fire an arrow if player is in range, and if not in range move closer to the player. Right now insted of shooting an arrow its supposed to instanciate a copy of an “arrow” object if at the “shooters” location. I’ve also copied a bit of code from the internet that i dont really understand. Neither the “arrow” instanciation nor the nav mesh agets are working (literally nothing is happening).

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

public class szczelaniebardzo : MonoBehaviour {

public Transform player; 
public GameObject arrow; 
public Transform shooter; 
public float speed = 6f; 
public float MaxRange = 200; 
UnityEngine.AI.NavMeshAgent nav;
public bool canShoot;
public float delayInSeconds;
public int Shot;

RaycastHit hit;
void Awake()
{
    player = GameObject.FindGameObjectWithTag("Player").transform; //locates "player", as he has the Player tag
    nav = GetComponent<UnityEngine.AI.NavMeshAgent>(); //uses Unity navigation UI
}
void Update()
{
    transform.LookAt(player.transform.position); //makes the shooter face target
    if (Shot == 0) //idk at this point i was trying to do anyting 
    {
        Shot = 1; //idk at this point i was trying to do anyting 
    }

    if (Shot == 1 && canShoot == true) //idk at this point i was trying to do anyting 
    {
        Shot = 0;
        if (Vector3.Distance(transform.position, player.position) < MaxRange) //checks if player is in range
        {
            if (Physics.Raycast(transform.position, (player.position - transform.position), out hit, MaxRange)) //does things i dont really understand 
            {
                if (hit.transform == player) //idk
                {
                    Instantiate(arrow, shooter.position, shooter.rotation); //spawns a copy of an item in front of the "shooter" object (deosnt work is not spawning, works when istead of shooter's coords i use player's, but spwans it on the player)
                    canShoot = false; //diables canShoot
                    StartCoroutine(ShootDelay()); //adds delay between shots to not instantiate an abject every frame

                }
            }
        }
        else //if not in range
        {
            nav.SetDestination(player.position); //uses unity nevigation UI to make shooter walk closer (doesn't work)
        }
    }

    

}
IEnumerator ShootDelay()
{
    yield return new WaitForSeconds(delayInSeconds); //Sets up the delay 
    canShoot = true; //anables canShoot
}

}
`

wow the code looks like mess for some reason. all enters disappeared for some reason