If it is a sunroof, that just lifts up manually, and when it's shut, it has glass that fits tight against a weatherstrip, then the above suggestions apply.
If it is a MOONROOF, where it can either lift up or slide back, is motorized, and does not have a tight seal against the weatherstripping, then you've got a different problem. Moonroofs are SUPPOSED to leak - sort of.
Open the moonroof all the way back, and look down into the cavity from the top of the truck. At each front corner of the cavity (and in some vehicles, the back corners as well) you will see a small hole. This is a drain hole, that is connected to tubing that runs down the A-pillar. Rain that gets past the roof seal collects in the cavity, and drains out through the drain holes.
The problem is that the drain holes get clogged up with dirt and crud - which means the rainwater overflows the cavity and leaks into the interior.
To fix, take an air compressor with a blowgun fitted. Wrap some electrical tape around the tip of the blowgun, to fashion a seal. Push the tip of the blowgun firmly into each hole, so that the electrical tape seals tightly against the edges of the drain hole. Blow air down the hole to clear the clog.
That's it! A pretty simple fix.