Tonight i was driving to my house and its out on the backroads and i was going up a hill and my truck just died

So i pulled off the road and i left it idleing and got out and looked at the tranny and the drive shaft and everything seemed fine then i got in my truck and put it in drive and pressed the gas and it didn't go anywhere. So i put it in park and reved it up and it worked fine. Then i shut the truck off, fired it back up and put it in drive and it drove fine. Does anyone think they know what the problem is?? I can't figure it out! If someone can please tell me whats goin on because its my daily driver and i have to fix it if its something bad. thanks a lot for looking