odd unparenting problem

Hi,

I instantiate two particle systems and set them as the child object of the player on trigger enter and then I check for a bool in the parent object and unparent the particle system from it’s parent if the bool changes and it works but only once. For some reason the particle system only instantiates as the child correctly once, after that it instantiates as a parentless object. heres my code:

First I instantiate OnTriggerEnter from the parent objects script and set the instantiated prefab as a child object of the parent as such:

  void OnTriggerEnter(Collider other)
    {
        if (other.tag == "AplaneFX")
        {
            GameObject GO = PhotonNetwork.Instantiate(aQuaplanningParticles.name, spawnPoint.transform.position, Quaternion.identity, 0);
            GameObject GO1 = PhotonNetwork.Instantiate(aQuaplanningParticles2.name, spawnPointAplaneParent2.transform.position, Quaternion.identity, 0);
            GO.transform.SetParent(spawnPoint.transform);
            GO1.transform.SetParent(spawnPointAplaneParent2.transform);
        }
    }

Then from the instantiated object, I check if the parent’s bool “showem” is false and if it is I unparent the instantiated object as such:

void Update () {

        if (transform.parent != null)
        {
            em.rateOverDistance = 800f;
            em.rateOverTime = 500f;

            if (transform.GetComponentInParent<CheckWater>().showem == false)
            {

                this.transform.SetParent(null);
            }
        

        }
        if (transform.parent == null)
        {

            StartCoroutine(destroyparticles());
            em.rateOverTime = 0f;
            Debug.Log("Particle system prefab has now unparented and is waiting to be destroyed");
        }
    }

Why are the new instantiations not parented can anybody see if/where I’m making a mistake??

Figured it out: Instead of calling the unparenting from the instantiated particle prefab I called it inside on trigger exit from the parent and now it works, for future reference i anyone’s interested