Re-enabling character control


I’ve searched all over for a simple answer to this and haven’t been able to find anything as it’s difficult to word what I actually want to happen.

Essentially, I’m trying to make the ease of disabling and re-enabling a player’s ability to move his character as seamless as possible. Which includes: if they’re holding down a key and I disable their movement, when their movement is re-enabled and they’re still holding that key, that key will continue to activate.

I.e: Holding down A makes you strafe to the side, if I disable your movement you stop, but if you still hold A and then I re-enable your movement again, I want it to start strafing again as if you never stopped.

local val = script.On;
local Opcodes = require(workspace.Opcodes);
local player = game.Players.LocalPlayer;

local playerModule = require(player.PlayerScripts:WaitForChild("PlayerModule"))
local control = playerModule:GetControls()

	if newVal == false then

If you don’t understand the question, please tell me as I know it’s confusing but I did my best :slight_smile:

Unfortunately, due to how the player controller module was made, it would require you to fork the existing scripts. The only way around this that I could think of that doesn’t involve forking would be to anchor the player’s character instead of disabling the control module.

See, back before when I used to script in the stone ages(lol), this is how you disabled a player’s ability to move their character. And this would work great, but unfortunately I’m using a MoveTo and I’m not sure if anchoring the player’s chest or something prohibits that function from working correctly.

Oh I see. Anchoring wouldn’t work then

That’s all I have in mind though. I personally think what you’re trying to achieve is kinda unnecessary, however it does impact UX greatly (I’ve experienced this issue before)

You could probably overcome this by tracking a player’s pressed down keys using User Input Service. If w is being held, then make the character move forward, if s then backwards etc.

I haven’t forked the character movement scripts to give a direct answer, but that’s essentially how I would do it.

Actually Anchoring might work

The only other thing( other than things already
mentioned) I can think of to stop player movement while still allowing “input” is to limit the player on all axises and disable their walking/running animations or set the walkspeed to zero

Tried anchoring, doesn’t move with MoveTo unfortunately.

A while ago, I answered a question that’s similar if not the same to yours.

This causes the player to freeze and restrict movement. Never anchor the character. It’s bad practice. Hope this helps!

Unfortunately this doesn’t work either. I’m essentially attempting to re-enable a character’s ability to move such that if they already have a key down, that key will engage. If he’s pressing A and I disable it, when I re-enable it and he’s still pressing A, he should start moving left.

Old thread but is the exact thing I’m looking for, I’m currently reading through the Control Module and I’m struggling to find a way to make this work as the way OP stated, does anyone have a solution for this already?

This post may help you.

Read what OP’s problem is, it has no relation to the topic you hyperlinked.