My speedometer is only working sometimes. It will work for a few days fine, then all of sudden stop working back and forth. I tried what you suggested and when it wasn't working I plugged a obc2 to my computer and it read the speed fine so I don't think the sensor is bad. Any idea what it could be?

when it acts up, plug in the obd 2 and if you have mileage speed then, either wiring from sensor to dash is bad or the dash unit itself