Before replacing the sensor, I recommend carefully opening it (if possible) and inspecting the potentiometer. It may look like a board with lines. First, check for any dust or dryness. If the sensor is dirty, spray a small amount of WD-40 or any non-conductive lubricant. Next, inspect the metal parts for dirt and clean them with a brush if necessary. After cleaning, apply a suitable amount of electrical grease to improve conductivity. Once done, reassemble the sensor carefully.
Most problems occur when the sensor fails to detect inputs due to dirt or insufficient contact. Hope this helps! If you have any doubts, feel free to ask.