Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.
When disabling controls of the character movements via PlayerModule Controls, I am unable to reenable them after a death. I attempted to call enable() during the died event, and also during the character loaded event, and on both cases, it did not properly enable controls. On both cases, I did it via an event to the client; and attempted to enable from within a localscript.
How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.
I have seen numerous posts for this same issue and unfortunately, none of them have had the solution and have died out or have been set to ‘solved’ for some reason or other.
The best would be to look at the Repro Place I have created and you’ll see it much clearer. Basically, > I disable the controls with controls.disable() and then I kill the player and then after the character has bee loaded, I have another button that I click that executes the controls.enable() method.
The expected result is for the enable() to allow the player to move, however, this is not happening.
It appears like there is no programmatic way to resolve the issue. I did find a way to get the control back to the player, but it is a manual process. After the character has been loaded, and the player is unable to move, if you click on the Disable Button and then click on the Enable Button, the controls are re-enabled successfully.
This is almost like disabling the controls (once again, as they are already disabled) brings back the scope/instance on which to work with. Then from this point, we can go ahead and enable them back successfully.
I also tried doing this programmatically (running a controls.disable(), controls.enable()) but it still did not work. It worked only when I went ahead and clicked on the buttons instead.
I list these instructions, on how to reproduce, it in the Repro Place. Just Play Solo and instructions can be followed to reproduce.
Would a screenshot or video help describe it to someone? If so, post one.
I have a Repro Place that shows how to reproduce the whole thing. I can also make a video and post it here.
Here is the Repro:
controls-repro.rbxl (22.1 KB)
You could see it live as well here:
When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.
It appears as this has been happening for months now as per the various posts that I have seen others open.
Anything else that you would want to know about the bug if it were your job to find and fix it.
I would look at the case that I show in the Repro Place. Programmatically, I am not able to get it back to enabled state, HOWEVER, I am able to get it back via manual steps by clicking on disable and enable ‘custom’ buttons.
After researching and attempting multiple things, I ended up applying this solution proposed by @TheGamer101
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
ContextActionService:BindAction(
FREEZE_ACTION,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
-- To unfreeze movement:
ContextActionService:UnbindAction(FREEZE_ACTION)
My hope was/is to use Controls.Disable() & Enable() and not have to use any surgical implementation, but for now, I’ll go with the proposed solution. I’m definitely interested in your feedback on this issue/manner.
Thank you very much!