Yes, that was something that I had in mind. Basically I want certain functions related to a certain level to stop running when the player is not on that level. Then when the player returns to the level again, the functions run again from the beginning.

When using flags like the one above, will the functions keep running once they are triggered whether the flag is on or not?

Right now, my program has been getting errors while it's running as soon as I change a level. It's trying to still call functions related to the old level and I want it to stop.