Two different problems as the speedo is mechanical, and the rev counter electric.
If the speedo works sometimes, check the teeth on the drive pinion in the gearbox, just undo speedo drive and pull it out.
The rev counter will most likely be a bad connection, so have a good wiggle whilst it is idling.
tabetha