hello, what year is this truck?
this sound like the front axle shift motor motor isn't working either due to a bad, shift actuator, gear selector switch or broken vacuum line.
The shift motor receives a vacuum signal from the switch mounted on the transfer case when the vehicle operator wants to switch from two wheel drive mode to four wheel drive mode, or vice versa. When this signal is received, the shift motor begins to move the shift fork and collar within the axle housing. In the four wheel drive mode, the shift collar connects the axle intermediate shaft to the axle shaft to supply engine power to both front wheels. In two wheel drive mode, the shift collar is disengaged from the intermediate shaft and the intermediate shaft is allowed to free-spin. When the two shafts are disengaged, the load on the engine is reduced, thereby providing better fuel economy and road handling.
this a diagram of how it works