My truck got into 2nd gear but after that it would not shift out of 2nd gear
Is this an automatic or stick shift?
The synchronizes are out or the clutch is not working. Possible worn clutch disc or faulty clutch master/slave cylinder.
Most likely a shift solenoid in the main valve body of the transmission.
Have a transmission shop or dealership scan the TRANSMISSION CODES, not just Engine Codes.