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.
@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.