The clicking is coming from the transfer case shift relays. To shift into 4H or 4L the computer has to see the following conditions:
1) Vehicle speed at or near 0
2) Foot on brake
3) Transmission in neutral
The transmission range selector is a known problem on these vehicles and can cause all kinds of problems. Before you start replacing shift motors, test the TRS first. You'll need an alldata or mitchell test procedure to do that.
ALLDATADIY.COM - Do It Yourself Automotive Diagnostic & Repair Information Mitchell 1 eAutoRepair - Do-it-Yourself Repair Information