Getting GetMoveVector and disabling player's movement possible?

I think this is an odd question, but i still wonder to know that is possible or not.

Yes, i have mix them with Controls:Disable() and GetMoveVector .

But that seen incompatible, Is there any way to make them compatible?

I’ll be so grateful for everyone to answered me.

My codes:

local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
pcall(function()
	Controls:Disable()
end)

RunService.RenderStepped:Connect(function()
	GetMoveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector()
	print(GetMoveVector) --Yup, i got (0,0,0)
end)
1 Like

You could try anchoring the HumanoidRootPart of the player’s character. I don’t know any other solution, sorry.

One “trick” usually used to disable the player’s movement is to use ContextActionService to unbind the keys WASD.

local ContextAction = game:GetService("ContextActionService")

function sinkInput()
    return Enum.ContextActionResult.Sink
    -- Sinks the key so that no action is taken.
    -- Since this will be the most recent bind to the key, it takes priority over default movement.
end

-- Disables movement.
function disableMovement()
    ContextAction:BindAction("DisableMovement", sinkInput, false, 
        Enum.KeyCode.W,
        Enum.KeyCode.A,
        Enum.KeyCode.S,
        Enum.KeyCode.D
    )
end

-- Unbinds our "disable movement" so that the default keybinds are activated.
function enableMovement()
     ContextAction:UnbindAction("DisableMovement")
end
1 Like

That was good and basic solution, also GetMoveVector printed currently.

But i still need player to move for some reason like MoveTo:(), so i don’t want take any Movement-blocking solution.

Yes, it does make player unmovable but also make GetMoveVector get (0,0,0) even when i’m using movement input.

And i don’t think this is a good solution because you still have to disable anything else like
mobile sticks and gamepad sticks.

Clarify why on earth you’d disable the controls then want to know if the player is moving. If you want to determine the velocity of the player then use BasePart.Velocity

Well, that’s why i said this may be an odd question.

I want to do that wherever people using WASD, gamepad leftstick or mobile stick, i could get which the player input like when i holding AS or make sticks to Left Down, GetMoveVector returns -1,0,1

Actually I’m coding a camera script, the camera type like League of legends but moving with GetMoveVector.

Not sure if this is the best solution but you could just set their walkspeed to 0. I can’t think of another way I’ve had a similar problem in the past

Well those are two different input types.

If you want to disable the controls and read off of the input I assume you’ll have to construct your own version.

Structure it like so

local Movement = {
	X = 0;
	Y = 0;
}

Then add connections to the controls and determine an appropriate camera movement ratio for the control. Using input keys you will need to use while loops to constantly get the movement. For gamepads use inputchanged to input the vector2s.

Then use a RenderStepped connection to move the camera based on the movement determined by the input OR just call a function the moves the camera by x amount.

That only works for computer though

I was just looking for a solution to this and found this post. Something that works is setting the player’s move function to nil:

-- assuming `player` is properly declared an initialized to represent the local player
player.Move = nil

With this, you should still be able to access the MoveVector.

1 Like