Bullet disappears for no reason

For some reason, sometimes when the player shoots the bullet is deleted immediately after shooting. It looks as if it is colliding with something so I debug.logged it but it doesn’t seem to be hitting anything that would delete it.

This is the code for shooting

    public float damage;
    public float travelLimit;
    public Rigidbody2D rb;
    public GameObject player;

    private void Update()
    {
        if(Vector2.Distance(transform.position, player.transform.position) >= travelLimit)
        {
            Destroy(gameObject);
        }
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        SpiderEnemyBehaviour spiderEnemy = other.GetComponent
            <SpiderEnemyBehaviour>();
        
        if(spiderEnemy != null)
        {
            spiderEnemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        if(other != null)
        {
            Debug.Log($"Bullet hit {other.name}");
        }        
    }

    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other != null)
        {
            Debug.Log($"Bullet hit {other.collider.name}");
        }
    }

Does the bullet work some of the time? If so is it possible that its hitting the player or another bullet?

This is also on the bullet correct? You have a distance checker for the bullet to the player, check to see if all the variables are assigned, if not it could be thinking that its farther than it is and be destroying itself. Put a unique debug at each possible destroy point to find which one is triggering it. Good luck!

Like @OnEd0t said, the bullet is probably hitting the player, give your player a tag called “player”, then try this

private void OnTriggerEnter2D(Collider2D other)
     {
         if (other.gameObject.tag != player)
{
//destroy your object or whatever
}
     }