Oh I see what you mean, since I had this kind of loop too, the way I delt with it was to manualy reset each of my variables (mostly bool', I love bool') when interacting with what I knew would be the last object players would interact with in the game: the last door. It may not have been the most optimized way to do it, but as long as I didn't forget a variable, I was sure it would be reseted xD (The truth is: as a beginner programmer it is quite intuitive to take the long inconvenient road instead of the built in functions already made for that exact purpose 🙂↕️)
I think on your game, my solution then would've been to manually reset all variable on the moment the player click on the finished nest (I dont say it is the right solution, I'm only projecting and wondering here. I would not give advices on something I'm so bad at)
but what a frustrating bug you encountered here XD