(in the end of the code...) when i try to run the program that tells me that the object is destoryed and i cant access it someone help?

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

public class Bullet : MonoBehaviour
{

private Transform target;
public float speed = 70f;
public GameObject impactEffect;
public void Seek (Transform _target)
{
    Debug.Log("seek");
    target = _target;
}

void Update()
{
    if (target == null)
    {
        Debug.Log("destroy");
        // Destroy(gameObject);
        return;
    }
    Debug.Log(target);
    Vector3 dir = target.position - transform.position;
	float distanceThisFrame = speed * Time.deltaTime;

    if (dir.magnitude <= distanceThisFrame)
    {
        HitTarget();
        return;
    }

    transform.Translate(dir.normalized * distanceThisFrame, Space.World);
    transform.LookAt(target);
}

void HitTarget()
{
    // GameObject effectIns = Instantiate(impactEffect, transform.position, transform.rotation);
    // Destroy(effectIns, 1f);
    // Debug.Log(target.gameObject);
    // if (gameObject != null) {
        
    //     Destroy(target.gameObject);
    // }
    Destroy(gameObject);
    
}

}

,using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{

private Transform target;
public float speed = 70f;
public GameObject impactEffect;
public void Seek (Transform _target)
{
    Debug.Log("seek");
    target = _target;
}

void Update()
{
    if (target == null)
    {
        Debug.Log("destroy");
        // Destroy(gameObject);
        return;
    }
    Debug.Log(target);
    Vector3 dir = target.position - transform.position;
	float distanceThisFrame = speed * Time.deltaTime;

    if (dir.magnitude <= distanceThisFrame)
    {
        HitTarget();
        return;
    }

    transform.Translate(dir.normalized * distanceThisFrame, Space.World);
    transform.LookAt(target);
}

void HitTarget()
{
    // GameObject effectIns = Instantiate(impactEffect, transform.position, transform.rotation);
    // Destroy(effectIns, 1f);
    // Debug.Log(target.gameObject);
    // if (gameObject != null) {
        
    //     Destroy(target.gameObject);
    // }
    Destroy(gameObject);
    
}

}

if you uncomment this

if (gameObject != null) 
{         
     Destroy(target.gameObject);
}

and comment this Destroy(gameObject); then you shouldn’t get that error.

it is still not working… but thanks