Speedo drive and driven gears have to be matched. You can't just swap in a driven gear willy-nilly and expect it to work, as you're finding out.
If you know what the transmission is (year and whether truck or car,) you can get a driven gear to match the drive gear that's in it. But you'd also need to know the rear end ratio that you have in order to get correct output from the speedometer.
See the bottom of
this page and also a couple more following it (click on Next Page near the bottom.)