obj doesn't read variable

Morkinas

Member
I have objGame that i put in a room, it's created first and has create > Execute code > selected = 0;

Then i have objChat step event > Execute code >

Code:
if (mouse_check_button_released(mb_left)){
 var str;
 switch (selected)
 {
  case 0: str = "TEXT1";break;
  case 1: str = "TEXT2";break;
 }
 scr_txt(str,1,oGame.x,oGame.y);
}
I get error: Variable objChat.selected(100017, -2147483648) not set before reading it.

If i give objChat create > selected = 0; it works but the problem is that i destroy and create it multiple times and i need value of (selected) to stay the same when i change it to more than 0.

Haven't used GM for a long time i think code like that used to work or i'm making really stupid mistake.
 
Top