I don’t believe you are supposed to purge a scene from within the scene. You shouldn’t have to purge a scene to reload it if you have all the right things in the right places.
Things outside of createScene()/enterScene() only happen once… ever… unless the scene is removed or un-required. So putting things at the top like:
local counter = 0
will only get set once. When you re-enter that scene, that code will not re-execute.
Code inside of createScene() only executes if the scene is brand new or it’s been purged. If you are reloading your scene, you probably don’t need to do this every time. Your scene is already in memory and you’re going to take a small performance hit to get rid of it all and re-create it. But if objects have moved and you need to reset them, or values change and they need reset, they won’t be reset when you re-enter because createScene() isn’t executed.
This leaves enterScene() as the magic location where you need to re-set things. Of course this can cause some visual trauma as things jump around, so we have some other events like willEnterScene() which gives you a chance to move things before the scene is transitioned onto the screen.
Once you get things in the right place you shouldn’t need to purge the scene to reload the scene.