It's rope physics! I followed a tutorial by Coder Archer on youtube. the video was super helpful and really awesome!
tutorial: https://www.youtube.com/watch?v=iwtC9nTptVw