Variable in a different class not changing

I’m trying to change the player’s position when they kill a certain number of enemies. However, upon testing just one, the player doesn’t move. It isn’t the actual moving of the player, but an issue where the variable in a different class doesn’t change.

Player script:

    public int enemiesDef;

    void Update() // Called once per frame so will handle all of the inputs from the user 
    {       
        if (enemiesDef == 1)
        {
            player.transform.position = new Vector2(-54.3f, 0f);
            enemiesDef = 0;
        }
    }

Enemy script:

    public GameObject player;
    private PlayerMovement pmove;

    private void Start()
    {
        pmove = player.GetComponent<PlayerMovement>(); 
    }
    
    public void TakeDamage(float damageAmount) // Method that takes in a damage amount as a float and inflicts it upon the enemy
    {
        health -= damageAmount; // The damage amount is taken away from the current health

        if (health <= 0) // If the enemy has not more health left once it has taken damage:
        {
            anim.SetTrigger("Death"); // Plays the death animation     
            Freeze(); // Calling the freeze method to stop the dead enemy from moving
            StartCoroutine (Wait()); // Calling the Wait coroutine to wait a second and then remove the game object from the game
        }
    }

    private IEnumerator Wait() // This is a coroutine to wait when an enemy dies
    {
        yield return new WaitForSeconds(1); // Waits for 1 second
        Destroy(gameObject); // Then it dies
        pmove.enemiesDef ++;
    }

What is “player” and what is “pmove?”

Most likely the thing you THINK you are changing is not the same one you think it is. You may be either observing or changing the one on disk (prefab) versus the one in the scene.

Here’s more reading:

Instancing and prefabs in Unity and naming your variables:

If you name your public / serialized fields (variables) as simply “thing” then you set yourself up for confusion.

If something is a prefab, name it that, such as public GameObject ThingPrefab; and only drag prefabs into it. Prefabs are “dead things (assets on disk) waiting to be Instantiated.”

If something is already in the scene or you Instantiate<T>(); it in code, then store the result in a properly-named variable such as private GameObject ThingInstance;

Naming is hard… name things WELL to reduce your own confusion and wasted time.