Door error

Sooooo, I have a script on one of my doors in my game that allows the key im holding to open the door and allow me to move onto the next scene by going through the door. It was working previously after I saved it last week. I made a few more changes to my game for an assignment for school that I did not need in my game, so after I submitted that assignment I clicked “do not save changes.” If anyone can help me it would be much appreciated. Also I am very new to scripting :slight_smile:

Here is the script for the door:

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

public class Door : MonoBehaviour
{

private PlayerAnimController thePlayer;

public SpriteRenderer theSR;
public Sprite doorOpenSprite;

public bool doorOpen, waitingToOpen;

// Start is called before the first frame update
void Start()
{
    thePlayer = FindObjectOfType<PlayerAnimController>();
}

// Update is called once per frame
void Update()
{
    if (waitingToOpen)
    {
        if (Vector3.Distance(thePlayer.followingKey.transform.position, transform.position) < 0.1f)
        {
            waitingToOpen = false;

            doorOpen = true;

            theSR.sprite = doorOpenSprite;

            thePlayer.followingKey.gameObject.SetActive(false);
            thePlayer.followingKey = null;
        }
    }

    if (doorOpen && Vector3.Distance(thePlayer.transform.position, transform.position) < 1f && Input.GetAxis("Vertical") > 0.5f)
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.tag == "Player")
    {
        if (thePlayer.followingKey != null)
        {
            thePlayer.followingKey.followTarget = transform;
            waitingToOpen = true;
        }
    }
}

}

Could it be that you’re not pressing the “w” or “up key” when you’re within 1 unit of the open door? Or does the door not open at all?