The flag in question is part of room0 in the room editor?
Ok this is basically what I see happening here.
room0 initializes and sets up the initial flag.
you drive into the flag and it transports you to the room where the race occurs.
crossing the finish line sends you back to room0 which now reruns its creation code and makes a brand new flag for you to repeat your race.
If you want to make the game world all a single room and want to move that flag to multiple locations you are going to need more overhead. Id say use arrays for this and you will need to make them globals that initialize that in a splash screen or something so the code only runs once.
Add one value to your obj_flag create code called index, and a global called race_index or something.
Code:
///inside create event of launcher room, just for kicks lets assume you have 3 flags in the room.
global.flag_cleared[2] = false;
global.flag_cleared[1] = false;
global.flag_cleared[0] = false;
global.flag_x[2] = 1024;
global.flag_x[1] = 726;
global.flag_x[0] = 128;
global.flag_y[2] = 852;
global.flag_y[1] = 456;
global.flag_y[0] = 963;
global.race_index = undefined;
Now in the room room0 creation code something along the lines of this.
Code:
///room0 creation code
var count = array_length_1d(global.flag_cleared);///you can use any of the arrays for this ass they MUST all be the same size
for(var i = 0; i < count; i++){
if(!global.flag_cleared[i]){
var setup = instance_create(global.flag_x[i], global.flag_y[i], obj_flag);
setup.index = i;
}
}
Ok so when player collides with the flag to transport to the race you need to set the race index.
Code:
global.race_index = index;
room_goto(whatever room you race in);
Now next thing is when you cross the finish line of the race you need to declare the race completed.
Code:
global.flag_cleared[global.race_index] = true;
room_goto(room0);
There are other ways to accomplish this. The main issue you are running into is that room_goto() re runs the initialization code every time, so if you leave the room and complete progress you have to be able to store that info someplace.
You will notice with my version you never have to destroy the flag, and the reason is when the create runs it will now detect that the flag was cleared, and effectively never gets put into the room.
Alternately you could add the flag and have it change to a completed state with a few more additions and when you drive up to the flag it could give you your past score and the option to replay.