How would I be able to move the player without the player being able to move

How would I be able to move the player without the player being able to move (for pc and mobile)

If I move the player using player:Move() I can’t just set walkspeed to 0. The only solution I have found is with contextactionservice but that does not seem to work for mobile

local controls = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule.ControlModule)
controls:Disable()
--or
controls:Enable()

In a local script. You can make it a remote event so you can disable player’s movement completely from the serverside but you’ll have to add an extra property to tell whether you want to enable or disable the movement.

6 Likes

@R_obotz 's solutions seems nice, I’m just adding that it’s considered a little better practice to use ContextActionService. There is absolutely nothing wrong with disabling controls, but PlayerModules are more often subject of change than ContextActionService is.

local CAS = game:GetService("ContextActionService")

local function freezeMovement(freeze)
	if (not freeze) then CAS:UnbindAction("FreezeControls"); return; end
	CAS:BindActionAtPriority(
		"FreezeControls",
		function() return Enum.ContextActionResult.Sink; end,
		false, Enum.ContextActionPriority.High.Value +1,
		unpack(Enum.PlayerActions:GetEnumItems())
	)
end

freezeMovement(true) -- false to unfreeze!

You bind and unbind action that sinks movement input.

Humanoid:Move() method accepts two parameters, which are directional vector and boolean that determines whether movement should be relative to the camera orientation (set it to false).

You may also want to consider using humanoid:MoveTo() combined with sunked actions.

1 Like

The problem with this is that it does not work for mobile

Well, I’m pretty the mobile controls can be disabled using R_obotz’s technique, so use that instead, I suppose. (It’s a different control module)

yeh I already put that answer as solution, why did you decide to revive this topic while it was already resolved?

Ah, pardon me. I just sorta thought I would comment it, and I didn’t realize that it was already resolved.

I believe the player can start moving again if they switch their controls (e.x. keyboard to click to move)

This is the case with breaking point