Deleted event's bugged

So i will have event occur and I have the command to erase event and it will erase it but whenever you enter a building and leave the event comes back up is this a bug? How can I fix this?
No, this is not a bug, that is precisely how 'erase event' is meant to work. You can use it, for example, to have on-map enemies respawn if you leave the map and return.

If you want an event to run once and then never again, you need to use a self switch. After the event has completed the action you want it to, turn on a self switch (typically A if there is only one page). Create a second page with nothing on it except have it conditioned by the self switch. Then when the event has run, it will go to that page and next time you enter the map nothing happens.

In Andar's compilation of info for new users, he links to an excellent playable tutorial on event commands. I think you would find it helpful to go through that so that you learn exactly how all the event commands work. It will save you a huge amount of time and frustration in the future.
So the best way to do it is make a event self switch got it it will just be a pain because I'm trying to do a collecting/harvesting system thank you for the help
You do have another option - if you want it to re-run at some time in the future so that you can collect it again, then you could use a global switch which is turned on/off by some other part of your harvesting system. But learning the differences between erase event, self switches etc. etc. is still necessary, so I think you would benefit from doing a quick run through of that tutorial I mentioned.

There are a number of plugins which have been written for farming-type games. You might want to look through the Plugin Releases section of the forum.

Original thread: https://forums.rpgmakerweb.com/threads/deleted-events-bugged.95009/