if statement running twice even though the statement is false

I have two if statements inside each other, however when the first if statement becomes false the other if statement still runs, but it only runs once. It is very wierd. I am currently making a flappy bird kind of game

void Update()
    {   
        if(!passed){
            if(Player.position.x >= gameObject.GetComponent<Transform>().position.x){
                Debug.Log("done");
                passed = true;
            }
        }
}

as you can see when it first starts the passed boolean turns true which means it shouldn’t run again however when I pass the obstacle for the first time it prints out “done” twice. This only occurs for the first obstacle.

if(!passed) is checking if passed is false. It’s turning to true later in your code. On the next Update call your passed bool will be true, so it won’t go through if(!passed).