Looks like you have 2 problems;
First, test for equal is ==, single =is an assignment.
Second, you can’t necessarily test for presence of the sensor by reading an output pin, but If there is an external pull up, in might work. More details would be required.
Fix the first problem first and then the second might be ok.
Regards