Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Disabling and Re-enabling the control script remembers key that was pressed?

I have an animation for my game that requires me to disable the control script so that the player cannot manually move their character during the animation since I am utilizing the humanoid moveto method. After the animation finishes, I re-enable the control script, but there seems to be a problem where if a wasd key was pressed when the script got disabled, it would remember that key and your character would keep moving in that direction after the script got re-enabled.

Here is an example of it in action, where I am not holding down anything after the roll is finished.

https://i.gyazo.com/3e838d8c6a4ac75997ddd84f6cb390b6.gif

I was wondering if there was a way to force the keyboard to "release" all keys, if that makes sense?

1 answer

✓ Accepted answer

You cannot, but you can do this instead of disabling the ControlScript:

local MasterControl = require(game.Players.LocalPlayer.PlayerScripts.ControlScript.MasterControl)

--When you want control disabled:
MasterControl:Disable()

--When you want control enabled again:
MasterControl:Enable()

This discussion is preserved as it was. New answers, comments, and votes are closed.