Checking if an event has been erased through a script call.

Hello so i'm making a game where you can fight enemies, and then after a certain amount of time they respawn.
Now my friend and I (mostly him) wrote a ruby script that allowed us to have that event respawn, through an event call.
But we need to only respawn the event if the event has been erased.

We tried this...
if $game_map.events[3].erase
$game_map.respawn_event(3)
end
$end

now the respawn event works. But what happens is instead of checking if the event has been erased. It just completely erases it. which confused both of us.

we also tried $game_map.events[3].erase = true and $game_map.events[3].erase?

but obviously those did not work.
If anybody knows how to do this I would be so grateful! HERE is the script we (mostly him) wrote.
upload_2018-2-8_20-6-53.png
You would need to create a new method to detect if it's erased first
Code:
class Game_Event
  def erased?
    return @erased
  end
end
Then to check, you can use the method
You would need to create a new method to detect if it's erased first
Code:
class Game_Event
  def erased?
    return @erased
  end
end
Then to check, you can use the method
Thank you so much!!!!! I figured it would just be making another method but I wasn't 100% sure on where to put it (EX Class Game_Event) Thank you so much again!
Moved to: Learning Ruby and RGSSx

Original thread: https://forums.rpgmakerweb.com/threads/checking-if-an-event-has-been-erased-through-a-script-call.91091/