Python scripts and Flags

I am using 2 output signals from a robot to switch between two python scripts in 2 sensors. But when I run the simulation, The whole program break down and I have to close Visual Components and re-open it.
Does anyone have an idea what might be the problem?
(The simulation was successful before i added the signals to switch between the python scripts)