The speed sensor is for the cruise control. The rest of it is for the speedometer and since it is a mechanical speedometer and the speedo gear looks good, it can only be one of the other three OR the discs that the speedo mesh with inside the transmission. I am temporarily excluding the transmission part since you indicate that it didn't work and then when you replaced the external stuff it worked for a few minutes. Check to make sure the cable is properly meshed with the speedometer. You could bring the entire cable inside the truck and use a cordless drill to spin the transmission end, (without the speed sensor attached and not too fast), to see if the speedometer indicates. If that works then the, the speed sensor may have broken internally. Also check the cable by itself to see if both ends turn when you spin the transmission end.
Good luck,
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
>-