Why don't you give the Spy character a variable that points to the current ghost or noone, and just do with(spyGhost) instance_destroy() before you create the new one? This would remove the need for the entire code below and make associatedCharacter obsolete.