Controls:Enable() not working?

wait(10)
local Controls = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule):GetControls()
print("contoled dissabled")
Controls:Disable()
wait(10)
Controls:Enable()
print("Controlled enabled")

error

Im using this in a game im working on. And it was working perfectly but suddenly its stops working and starts to give this error.

I thought it maybe because some code buggin it but then i tride the Enable/Disable functoin and in a total new place and its giving this error.

Anyone can tell any solution? Or something that i can use enable/disable player contol?

1 Like
1 Like

While I’m not sure why your script isn’t working, you can use ContextActionService to temporarily bind over the control keys.

local ContextActionService = game:GetService("ContextActionService")

function donothing ()
	
end

ContextActionService:BindAction("hi",donothing,false,Enum.KeyCode.A)

task.wait(5)

ContextActionService:UnbindAction("hi")

Someone already replied with a useful solution, but this is just an example of a script that temporarily disables the A key.