gsap.registerPlugin(MotionPathPlugin,MotionPathHelper); let tween = gsap.to("#id", { motionPath: { path: "#path", align: "#path", alignOrigin: [0.5, 0.5], }, }); // pass the tween instance in here... MotionPathHelper.create(tween); document.getElementById('replay').addEventListener('click',()=>tween.restart());