How would i stop player movement?

This is a simple issue, i don’t know how to stop player movement.

PS. I know this has been answered multiple times in this category, however, none of the answers work currently.

4 Likes

What do you mean by this?
Stop the player controlling the character?
Or:
Set the speed to 0?

Setting the speed by 0 is not possible, as the character actually moves alone.
What i want to do is to stop the player’s controls from doing anything.

1 Like

To stop the player control, use something like this:

-- This require statement gathers the new player scripts.
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

-- In order to access controls, you must first get the controls
local Controls = PlayerModule:GetControls()
-- For Cameras, use PlayerModule:GetCameras()

--[==[ You have now obtained the new control methods! Yay! ]==]--

-- In order to enable controls, you need to use the reference Controls instance and call the Enable method within it.
Controls:Enable()

-- In order to disable controls, you need to use the reference Controls instance and call the Disable method within it
Controls:Disable()
3 Likes

I’ve already tried to do that, the character moves anyway.

What do you mean? Yes they do work. I recently answered a similar question.

If you search, actually try the solutions. I don’t think you were reading the right solutions or inputting the correct search terms.

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindActionAtPriority("disableMovement", function()
    return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.Default.Value + 50, Enum.PlayerActions:GetEnumItems())

I did try all the answers, only 1 kinda worked, but it wasn’t consistent.

This is as consistent an answer you can get. Unbind the player movement actions via ContextActionService or bind a higher action that sinks the input of the control type, as I just posted.

Your code gave me a error (ContextActionService:BindAction called with an invalid hotkey (should be either Enum.KeyCode, Enum.UserInputType or string)

My code does work.

Make sure the settings are like this?
image

1 Like

Indeed, the settings are equal.

So just switch the input type then? You shouldn’t just copy and paste my code, then tell me it doesn’t work if it doesn’t. Do some debugging yourself. Change the arguments, like use Enum.PlayerActions.CharacterBackward. Not sure how you’re getting an error with my code anyhow.

An exact console error would be appreciated, not a vague guess.

Try this code:

-- This require statement gathers the new player scripts.
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

-- In order to access controls, you must first get the controls
local Controls = PlayerModule:GetControls()
-- For Cameras, use PlayerModule:GetCameras()

--[==[ You have now obtained the new control methods! Yay! ]==]--

-- In order to enable controls, you need to use the reference Controls instance and call the Enable method within it.
print("In 3 seconds, the controls will be disabled")
wait(3)
-- In order to disable controls, you need to use the reference Controls instance and call the Disable method within it
Controls:Disable()
print("Time to enable it in 3 seconds.")
wait(3)
Controls:Enable()

If it works, make sure to add the :white_check_mark:. (:

20 Likes

I did give you the exact output…

2 Likes

That’s BindAction, not BindActionAtPriority. BindActionAtPriority incorporates another argument due to needing to specify a priority level. Argument 4 of BindAction is the input type, while it is the priority level for BindActionAtPriority.

2 Likes

Do I put this in StarterPlayerScripts?