Disabling Character Controls?

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

16 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()
72 Likes

Ye thanks, I figured it out a while ago but still thank you :slight_smile:

1 Like

and to enable them you write

Controls:Enable()

right?

4 Likes

Yes, you can also use Enable to Disable the controls:

Controls:Enable(true) --// Enables
Controls:Enable(false) --// Disables
7 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

Yes you can, with:

Controls:Enable()
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)

1 Like

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
)
6 Likes

But… PlayerScripts is not a valid member of Player “Players.Player1”

It’s on the client, and if it isn’t, it needs to be. So you would need to use WaitForChild as client scripts can run before all game assets are loaded.

Just for future reference, this is a pretty old topic, so please try to avoid bumping topics like these in the future!

1 Like

Yes sorry for bumping but when you start a new topic you have to make sure a similar one doesn’t exist. And since I have this problem currently, I try to figure why the solutions above don’t work for me.
I’m trying to move the player’s character from a part to another part without being interfered by controls like key inputs. I managed to disable the jump but I don’t know why I can still move when the game is trying to move myself automatically.

Did you try the WaitForChild suggestion I said before? Might there be other scripts interfering? The controls disabling seems to work fine for me.

1 Like

I coded badly the wait for child! Thank you I fixed my issue!

1 Like