I was having the same problem, I tried to buy a new speedo gear, this is inside the transfer case on the drivers side. There is a 1/2 bolt holding it in. Sometimes the gear wears out. I tried finding a new one, but I could not get what I needed anywhere. The dealer wanted a $100+ for it. One day it started working and has been for 2 weeks now. I also noticed my engines idles great now, it used to drop at a stop to about 300-400rpms then would be fine. I am thinking I may have an electrical problem somewhere.
I know this doesn't help much.