Typically with the sliding moonroof the entire assembly is bolted to rails that run front to back. To access it the headliner needs to come down. If you’re going to do that job it’s time to consider redoing the headliner if at all interested and definitely add hushmat to the roof to remove the huge white noise we’re all used to in the truck.
Once the assembly is accessible you can undo about 8 bolts, harness connector, sunroof drain tides and the entire assembly drops out with the sliding shade. The glass can be removed at this point. You’ll need at least a 4x6 table to lay it on. DO NOT break or crack the sunroof drain spigots where the tubes connect or u r screwed.
Those sunroof drain spigots may protrude on each corner keeping you from laying the assembly on its side without snapping them. ONLY lay the assembly flat on a table. If the drain tubes won’t disconnect from the spigots, use a hair dryer to soften the tubing so you don’t snap the spigots off. Don’t let the drain tubes fall in the body cavity or they’re gone forever.
When the glass is off the assembly don’t replace the seal. If you find a new one the sunroof won’t close until your thumbs fall off pressing the new seal on the glass to make the needed tolerance. Find a used sunroof with a better seal. They should last 20-30 years.
Set a thick moving blanket on the roof of the truck. Set the assembly on the blanket. Connect the harness to the assembled moonroof on the roof through the sunroof opening. Power up the moonroof and operate it several cycles on the blanket to ensure it’s operational before you install it. Clean the old grease out then lube the tracks with dielectric grease. If all good, install it and test it again before installing the headliner.
BTW the moonroof seals are made to leak. It’s the drains that get rid of the water along the edges of the moonroof. Use an old speedo cable or similar to clean the sunroof drains before you take it apart.