Here is how to fix it:
First of all, when you try to launch Hammer, it will say that the gameinfo.txt is missing. So, go to that folder of the new location of tf2 (the tf folder) and copy gameinfo.txt. Then, go to the original install location of TF2 (probably in the C drive) and create the folders that it said that gameinfo.txt was in (C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf). Then, paste gameinfo.txt into the folder (tf) and launch Hammer (with Team Fortress 2 configuration).
The next step is to go to Tools in Hammer, the options.
Then look at this guide to input the
Game Data Files,
Game Executable Directory, Game Directory, and the
Hammer VMF Directory.
Hopefully this helps those of you in the future who have the same problem as I just experienced!
EDIT: You will also have to change the directories in the Build Programs tab of the options menu.