try changing the distance and vertical alignment between the sensor and the wheel-mounted magnet.
If that doesn’t help, the sensor (or its cable) mounted to the fork is probably broken. Check the cable for any visible damage. I think the sensors are usually cheap&simple reed switches to detect...