Collider2 is trigger else part doesnt work

Hello,variable of toprenk gets another script. This part is ok and rengim is a veriable that I entered by my hands. So the problem is my codes dont work after else. I mean isTrigger = true is working but if rengim doesn’t equal to toprenk this part doesn’t work.

Let me explain my game. I have a ball blue and yellow. I have also blue and yellow barriers. If my ball is blue, it can pass from blue barrier, if my ball is yellow, it can pass from yellow barrier.

But as I said, else of part doesnt work. And I think the problem is about collider2d.

I am waiting for your helps

using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class renk : MonoBehaviour {
        public string rengim;
        public string toprenk;
     void Update () {
    		if(rengim == toprenk)
               GameObject.Find("" + rengim + "-portal").GetComponent<Collider2D>().isTrigger = true; 
             GameObject.Find("" + rengim + "-portal").GetComponent<Collider2D>().isTrigger = false;

can someone help me :confused: