Set Map Name as Variable

So when I try to use "Control Variables : #0010 Respawn Town = $gameMap.displayName()" I get the starting map's name stored correctly... However when I get to the 2nd town the variable is stored as 0... any ideas why?
Thanks!
I'm almost certain that a variable has to be numerical.
If you're trying to have the game store the value of a specific area (which is what I assume, correct me if Im wrong) what you need to do is look at the top left corner of the "EDIT MAP" Window. It shows the ID number of that map. Set your variable to that.
a63422fa771af73115db847a4d50792c.png

Where it says ID: 001
OH almost forgot: You can get the ID number of the map directly by doing this command:
b18423ad19c3cfa92a968a7a71120323.png
Actually, you can store almost any kind of data in a variable. Text should be more than fine.

@PhxFire Could you give an example of how you are retrieving the variable? Is the variable set once per map, or just once at the beginning of the game? Is there perhaps a control variable event command that is resetting the variable somewhere?
So when I try to use "Control Variables : #0010 Respawn Town = $gameMap.displayname()" I get the starting map's name stored correctly... However when I get to the 2nd town the variable is stored as 0... any ideas why?
Thanks!

Just so you know, $gameMap.displayname() is incorrect; it should be $gameMap.displayName()
Also, are you sure that the map has a display name in the first place?
@Jules98 Ya it's correct in game, just made the mistake typing it in the forums

@Ossra The variable is set to the 1st town at the beginning of the game (which works correctly)... Then overwritten each time they make it to the next town with a 1 time parallel event

Edit: Yup I found the mistake, the display name must've been deleted at some point 😔 It's always the simple things lol thanks guys!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/set-map-name-as-variable.112979/