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.
Oh, I have no idea how those objects work. I'd remove it and add this to the warping code:
player.x = 400
player.y = 300
That would go to the center of the room, but just change it to whatever you want.