Never mind, I have figured out a way. I did take a more complicated way, I think, but it works. I just made a variable for all the directions, and made it so when I press an arrow key, it turns on the variable for the key I pressed, and turns off the other ones. Then in a _physics_process, I made it so if one of the variables equals true, it plays that animation.
I think that my problem was that since the script runs every frame, it was resetting the animations every frame as well, making it just be stuck on one frame. I am sorry for the inconvenience of asking this question, when I had an easy way to do it myself.