Make the character respond to traffic lights

I am trying to build a traffic light system where the pedestrians respond to the lights but I am not sure how. My codes do not seem to work