My code doesn't see one of my functions?

This code is calling a function when it collides with ‘Enemy’

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

public class bullet : MonoBehaviour
{
    public float speed = 20f;
    public Rigidbody2D rb;

    // Start is called before the first frame update
    void Start()
    {
        rb.velocity = transform.up * speed;
    }

    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy badGuy = hitInfo.GetComponent<Enemy>();
        if(badGuy != null)
        {
            badGuy.die();
        }

        Destroy(gameObject);
    }   

}

Line 21 is the error (Assets\bullet.cs(21,20): error CS1061: ) and it’s being crazy over the “.die” part
it says there is no definition " ‘Enemy’ does not contain a definition for ‘die’ and no accessible extension method ‘die’ accepting a first argument of type ‘Enemy’ could be found (are you missing a using directive or an assembly reference?)"

Here is my other code where the method is.

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

public class Enemy : MonoBehaviour
{
    public void die()
    {
        Destroy(gameObject);
    }
}

Help please. I can’t find the problem.

Have you saved the changes to both of your scripts? Double check - I have seen Visual Studio bugs where it won’t save when you hit ctrl+S
Have you created more than one script called Enemy?

The problem isn’t in this two pieces of code. You probably have another Enemy script in your project under a namespace and you’re adding that onto your enemy object. Or something similar.

Oh, let me check. Would names of gameObjects confuse it?

I double-checked, still an error.

No the names of GameObjects are irrelevant to this problem. It’s purely about the code.

Okay, because I have a GameObject also named Enemy. I don’t understand what else could be the problem though.
I don’t have any other scripts named “enemy” or “Enemy”, just the one.

Line 18 , top script, right-click on Enemy and select go to definition.

Is it what you expect?

Wait… The error randomly went away? I’m very confused but happy. lol. thanks anyways guys.

And yes. Apparently now its fixed, That was very wierd