Player controls re-enabling after :GetControls():Disable()

local client = game.Players.LocalPlayer

local playerModule = require(client.PlayerScripts:WaitForChild("PlayerModule"))

local controls = playerModule:GetControls()

controls:Disable()

print("Disabled controls.")

I published this to a game with a single local script containing the above. I joined the game 3 times and the controls were properly disabled. On my 4th try the controls were not disabled.

What could be causing this? I’m not entirely convinced this is an engine bug (possibly just a bug with PlayerModule), but It’s highly impacting our game.

This also seems to only affect actual in-game, and never studio.

EDIT: I filed a bug report here: Minimized window bypassing ContextActionService:UnbindAllActions()

3 Likes

Hi, I tried the script and it was always working and there weren’t any bugs with it even in studio.

Did you try in a live game, and re-join several times?

yes I did try it lots of times, and if it makes a difference I put the local script in the StarterPlayerScripts

does it work now? Or is it still not working properly?

It’s still giving us trouble, I have no idea what the problem could be. I even tried cas:UnbindAllActions() in the same way as the script I provided, and even that has the same problem.

I have tried putting a wait in because the PlayerModule might not have loaded in yet so try this:

local client = game.Players.LocalPlayer

local playerModule = require(client.PlayerScripts:WaitForChild(“PlayerModule”))

local controls = playerModule:GetControls()

wait(0.2)

controls:Disable()

print(“Disabled controls.”)

Join this place, press f9 and wait 5 seconds until it says your controls disable. I joined 4 times and on my 5th try I am able to walk around despite the following code being ran:

local cas = game:GetService("ContextActionService")

wait(5)

cas:UnbindAllActions()

print("Controls disabled.")

try this:

local ContextActionService = game:GetService(“ContextActionService”)
local FREEZE_ACTION = “freezeMovement”

wait(0.2)
ContextActionService:BindAction(
FREEZE_ACTION,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)

2 Likes

Does it work with my code, or does it still not work? and I don’t have access anymore to the game.

1 Like

Was able to reproduce the same bug with your code, I’m seemingly able to reproduce it 100% of the time if I start roblox minimized and then open the client a few seconds later.

I’m leaning towards this is an engine bug since only some players can reproduce this, thanks for your help and testing though.

too bad we couldn’t fix it. But at least you know what the problem is.

try this out and tell me if you can’t move around or if you can.

Sorry for the late reply, I found a solution for this. Use ContextActionService instead! How to stop player movement! - #2 by GollyGreg

local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"

-- To freeze
ContextActionService:BindAction(
    FREEZE_ACTION,
    function() return Enum.ContextActionResult.Sink end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)


-- To unfreeze
ContextActionService:UnbindAction(FREEZE_ACTION)
1 Like

This was already stated prior:

Also, please provide the source of which you got this from–especially if you found a solution. This was from another post, I believe:

Cheers.

1 Like

My apologies. I didn’t see it.