var counter; as global veriable is running always with f.e. if(player !=0) wait(-1); function. So it doesn't matter where your player will be, counter will be counting. You may change counting like if player is in secret level then +1 (reward extra time) by time_step and if in main level -1 by frame_step.
Or maybe I still don't get it
