GameMaker refers to all assets in the game (sprites, sounds, objects, rooms, etc) as numbers, aka their index. When you write code that refers to objPlayer for example, GameMaker actually uses objPlayer as a shortcut for its index.
In order to get the index of the room with code like that I think you need to use asset_get_index(), and in order to use asset_get_index() you need a string that refers to its name.
Special thanks to Age on the Skype group.