Confused how to communicate esp8266 12e with arduino nano

Please read the forum guidelines in the sticky post, then edit and correct your post #7.

How do you know the sensor is detecting something?

Reading your code, I suspect the sensor only pings once, immediately after a new command is received. Then the motors start. After that, no more pings until the next command is received. So an obstacle in the way is not detected. This is because of this line in your sketch:

if (!client) return;