Sounds like one of two problems. First measure the travel of the slave cylinder at the release lever on left side of the transmission. If it’s not fully releasing problems will occur. Second, when the problem is occurring, put the vehicle in neutral and pump the clutch pedal to see if the transmission goes into gear without grinding. These problems are associated with hydraulic failure. A faulty pressure plate has also been known to cause this condition.