Moving ship sail tween help

im making a sail for a ship tween open and close and it works fine if the tween goes all the way through (you can stop the tween anytime by releasing W or S) but if you stop it early and then switch which way you are going (if you were holding W now holding S) it will reset the time to get there making it go very slow (see video for better explanation)

when you switch which key you are holding it will cancel the current tween, create a new one with the new position. if you dont switch it will pause and unpause. im wondering if you can change the tween data without having to create a new one and save the time it already took.

i tried storing the current time when i create the tween then when i switch keys get the time elapsed and changing the time needed to complete the tween before creating a new one but that would mess up the actual time needed and sometimes it wouldnt even give me the right value (for exmaple: one time it gave me 5012852 seconds elapsed, i used os.time()). the second problem with this is if the player stopped the sail then didnt move it again for a while the elapsed time would be way more than it should

in short:

  • is there anyway to change the tween data without having to create a new tween
  • am i doing the time storing and grabbing wrong?
  • is there anyway to stop a tween then reverse it with the same amount of time it took to get to its current position (another way of changing tween data without creating a new one)

figured it out by saving tick() when i play the tween then when i switch the sail direction by using tonumber(string.format("%0.2f", tick() - lastTime), 10) lastTime being the saved tick()

then to fix the issue of the number because very big i just make sure its not above the normal move time

edit: this didnt work so i switched by getting the distance between the two attachments when switching keys and that will give me the percentage completed and times that by the max move time to give me how much time is left