Player Controls Disabled but Pressing Key and Held Key Value Never Disabled (SOLVED IT)

Hello, I’ve been trying to find a way to work around the Roblox Controls:Disable() function while forcing a player to move to a certain point with MoveTo but having them be able to cancel it by pressing space.

The way the code works is it plays the MoveTo for the player until they press but when it does the MoveTo function it also does Controls:Disable() so the player can’t cancel the MoveTo unless UIS input is specifically “Space” and then it Re-Enables the controls.

Problem is that once the controls are Re-Enabled it doesn’t recognize which keys might have been pressed beforehand and held and won’t move because the key according to Lua code when controls were disabled has never been “pressed”.

I tried disabling the MoveTo by setting it to the player’s current position and that works but due to the controls being taken until the MoveTo finished it doesn’t recognize the player’s keys that are held down by the time controls were given back.

I have an idea of how to make the held key persist and that would be not to use controls:Disable() at all and instead make the Main PlayerModule.Movement script movement keys when pressed and held not do their moving action while local movementDisable = true and since any key continues to repeat itself while held if I simply change the movementDisable value to false then it would go through while still knowing the key was pressed and actually moving the player that time.
^ I don’t think this would affect the MoveTo function since no movement is actually being made just like clicking with your mouse.

Is there any way to go around this to allow for the held key value to continue through controls being disabled? Or would my idea of checking if key is pressed and if state requires it not to run its movement function in the main PlayerModule Movement script be the way to go? And if so where in the player module movement script/keyboard script would I implement the state checker?

Please let me know. Thank you!

Hello, I’m sorry for responding to this a year later, but I’m having the same issue and sadly this is the only post I could find where someone managed to solve it, but you never said how you solved it. Do you mind telling me cause I need to make it so the player’s last key is held before their movement was disabled so they don’t loose their speed in my game. Thank you!