Basically at the end of the loop it seems like the torso and arms go into a position, but the legs are not affected. The animation is on loop and is set to “movement” priority. I used the basic animate script from roblox.
After a while I figured that the problem came from the fact that not every body part is set during the first frame. In the roblox animation editor, it looks fine if the frame is set later in the animation but apparently it breaks in game. Anyways, it’s hard to explain but at least it works fine now.