The correct function usage is ControlModule:Enable(Bool)
Your code would work if you included a true bool in the Enable function.
local controls =require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()
wait()
controls:Enable(true)
The Disable function has no expected arguments. For those curious, including a logically false (false, nil, etc.) value in Enable… disables the active control module.
There are some other issues with your code (e.g. indentation, format, etc.) but that is beyond the scope of this reply, please ask me if you need advice with that.
If this reply has helped you, please mark it as a solution by pressing the button below
Try doing this instead. I’m not too familiar with disabling player controls using that module but I tested it and it seems to work. It takes a bool value and the bool value you put in is the result you will get.
repeat wait() until game.Players.LocalPlayer
local controls =require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Enable(false)
wait(5)
controls:Enable(true)
Also, you were running it instantly which could possibly run before the player even loads so it’s always a good idea to verify the player is there.
The thing is, the code seems to work fine with just controls:Enable(). It just seems to entirely disregard the controls on respawning. I was only able to grant myself movement again by forcing this with the command bar for some reason, having a localscript doing the exact same by the press of a button however did not.
I was just about to post a message regarding this same issue.
@Dynastorious - have you been able to find a resolution on this?
@KingOfGenres had posted the same issue months ago, but unfortunately, his thread just ended with no resolution. @KingOfGenres - did you ever find a resolution for this? Your thread is here:
@Dynastorious - unfortunately, I just noticed you had set this to resolved, but the solution listed does not seem to be the issue in my case. I might open a new post and go with that instead.
@tragoblue Not my post, wasn’t me that set it to solved. Alas I was unable to find a decent fix for this so I commented it in my code and went with just changing walkspeed for now, hoping a decent solution would come.
Basically, you can disable and enable movements on the character via the PlayerModule’s Controller.
It works great, that is unless you die and respawn prior to re-enabling the movenents, at which case, you will not be able to regain movement by calling the enable().
There has been suggestions to use other things such as binding actions, using priorities, using walkspeeds, but all of these solutions smell to me. The PlayerModule was changed/enhanced a few months back and should be the only way to do this without requiring surgical work. I have submitted a bug report to Roblox so I’m hoping to get some feedback from them on this issue.
@Dynastorious - oh, sorry, I thought this was your post. Yeah, unfortunately, I might have to look for some other workaround to get this behavior (perhaps what you said about the Walkspeed).
[EDIT]
FYI, in case anyone finds this post with same problem as mine, I went with this solution: