isTrigger not working

So I want this script to turn a door into a trigger so the player can go through it, then become a non-trigger when another door is opened, but the “().isTrigger = true;” won’t work

        if (isYellow == true)
        {
            foreach(GameObject Thingy in YellowDoors)
            {
                Thingy.GetComponent<Renderer>().sharedMaterial.color = new Color(1, 1, 0, 0.25f);
                Thingy.GetComponent<Collider>().isTrigger = true;
            }
        }

The line up the isTrigger line works, meaning that the foreach function is working, just not for the trigger.

Do you have a collider?
a common mistake is to find the collider in the parent object, and it does not detect it …
try with .

anywhere, post a photo!

in addition, im sure you need a rigidbody for triggers.