How do I disable the Character’s Controls?
I’m a bit out of date on roblox, I still remember that there used to be a Local Script “ControlScript”
that I used to disabled to make the player lose control of it’s character. But now all I see is the ControlModule which I cant seem to find to disable and it doesn’t list out functions in the script.
Help pls
11 Likes
The PlayerModule, found in PlayerScripts, has a GetControls function which returns the Controls class - this then has Enable/Disable methods.
Here’s an example of using it:
local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
Controls:Disable()
56 Likes
Ye thanks, I figured it out a while ago but still thank you
1 Like
and to enable them you write
Controls:Enable()
right?
2 Likes
Yes, you can also use Enable to Disable the controls:
Controls:Enable(true) --// Enables
Controls:Enable(false) --// Disables
6 Likes
if you mean to how to just change the humanoid settings you can do that by this thing: insert humanoid in starterplayer then change the values and thats all.
5 Likes
Nah I already knew that anything that goes in startplayer if exists in the Character will replace it, but thanks though.
2 Likes
I am having kinda the same problem as @DXPOHIHIHI and can you enable it with this script too?
2 Likes
would you be able to disable a specific control within this module?
such as making it so the player couldn’t move forwards or back (disabling w and s)
Via the Controls class? I don’t believe so.
However, you can potentially bind at a high priority for moving forwards and back and return Sink so that it isn’t processed:
local ContextActionService = game:GetService("ContextActionService");
ContextActionService:BindActionAtPriority(
"SinkKeys",
function()
return Enum.ContextActionResult.Sink;
end,
false,
Enum.ContextActionPriority.High.Value,
Enum.PlayerActions.CharacterForward,
Enum.PlayerActions.CharacterBackward
)
4 Likes