Run a Prefab while ONLY in the trigger zone.

Hi guys!

Been puzzled by this for the last 4 hours. In a nutshell, I only want my Particle PreFab to run while my “Player” tag is in the trigger zone. Right now, I can instantiate the Prefab “Visual” when “Player” enters the trigger zone however its trying to stop the prefab when the “player” leaves that I’m finding difficult. My current code obviously gives me “Destroying assets is not permitted”

As I’m still a bit new i’m having trouble accessing the myPart Prefab (Clone) to delete upon my “Player”'s exit trigger.

Any help is much appreciated.

`public GameObject visual;

void OnTriggerEnter(Collider col)
{
			if (col.gameObject.tag == "Player") 
			{
	
		GameObject myPart = (GameObject)Instantiate (visual);
	
			}
}

void OnTriggerExit(Collider col){
			if (col.gameObject.tag == "Player") {

		Destroy(visual);
					
			}
	}`

Just store visualClone as an empty GameObject variable:

 private GameObject visualsClone;

Then when entering the “zone” assign new instance to this variable:

 void OnTriggerEnter(Collider col){
    if(visualsClone == null) visualsClone = Instantiate(Visuals) as GameObject;
 }

And when exiting zone:

void OnTriggerExit(Collider col){
    if(visualsClone != null) Destroy(visualsClone.gameObject);
}