Hi Amber:
There is no direct bus transportation from Magic Kingdom to Downtown Disney where T-Rex is located. Instead, I would take the 10 minute casual stroll from Magic Kingdom to the Contemporary Resort to catch a direct bus from the Contemporary to Downtown Disney. Buses are scheduled to run every twenty minutes, but I find they tend to run on a quicker schedule. So I would allow up to 60 minutes to take a slow stroll to the Contemporary, wait for a bus, commute to Downtown Disney, then stroll to T-Rex, however, it's likely to take only 45 minutes, especially if you walk with purpose. If you arrive early, you can always take in the shops at Downtown Disney.
Disney World's complimentary transportation is
available up to one hour after Disney Theme Park closing times. While I've seen transportation run a bit later than on occasion (usually due to high crowd level), if the Animal Kingdom closes at 6:00pm on the day in question, I cannot guarantee that you will be able to catch a Disney bus with such a late reservation. If you don't have a car with you, I would rely on a taxi if buses are no longer making pick-ups at the Park at the conclusion of your dinner.
Enjoy your vacation.