The problem is line 8(null reference)
private void Start()
{
timeBtwShots = startTimeBtwShots;
}
private void Update()
{
if (target.position != null)
{
Vector3 difference = target.position - transform.position;
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
}
if (timeBtwShots <= 0)
{
Instantiate(projectile, shotpoint.position, transform.rotation);
timeBtwShots = startTimeBtwShots;
}else
{
timeBtwShots -= Time.deltaTime;
}
}
}
,