Okay, I see what you mean. Assuming you're using the YoYo Engine, I'd recommend just making use of the built-in secret array if custom code isn't working.
Make an object in the hub room with the create code:
global.saveSecretItem[1] = true;
Then check if that's true before executing the code you're using to bring the player back. Something like:
// Event for whatever key you want pressed
if global.saveSecretItem[1] = true {
player.room = [whatever the hub room's name is];}
Assuming I'm reading the code in the engine right, this is already built into it. The only thing is that the player will need to save once after entering the hub for that variable to save.