Prevent movement (without anchoring HRP, disabling WalkSpeed, unbinding controls)

I’m having trouble trying to find a way of preventing the player from moving without breaking certain mechanics in my game.

At first I was unbinding the movement controls, which worked well for a while, until I needed to allow the WASD keys for moving a free camera, but when those keys are unbinded from movement, they return true with GameProcessedEvent and thus creates problems.

Next idea was to anchor HumanoidRootPart and setting WalkSpeed to 0. This however creates the problem of preventing me from using Humanoid:WalkTo()

So is there another solution to this problem?

1 Like

Can’t you just un-anchor the HRP, call Humanoid:WalkTo() when needed and then set Anchored to true again?

No cause a player can interrupt the WalkTo function. I want the player to be forced to move to a certain position and not allow them to move off it at all

I don’t think there’s a way to prevent movement via the second option and allow an exception through Humanoid:MoveTo(), you’ll probably only need to prevent input for movement.

Try this:

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()

You can use Humanoid:WalkTo() as well without it being possibly interrupted.

Edit:

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Enable() -- enable

image

@ PlayerScripts.PlayerModule.ControlModule

1 Like

If that disables movement, how can I re-enable it?

When the “controls:Enable()” script is activated, jumps that the character has not entered are infinite, and direction keys are not input. Do you have any solution?

It’s been over 2 years since I sent the reply you responded to and I’ve quit doing mostly anything on the platform, so I cannot answer you, unfortunately.