What do you want to achieve? I’m currently trying to make a custom movement system which relies heavily on Humanoid.MoveDirection. I’m currently looking to implement a custom walking system with wider turns using Humanoid:Move().
What is the issue? I cannot disable the player’s default walking without nullifiying Humanoid.MoveDirection.
What solutions have you tried so far? So far I have tried:
Setting Humanoid.WalkSpeed to 0, this causes Humanoid:Walk() to not do anything.
Setting the Humanoid.DevMovementModes to scriptable, this nullifies Humanoid.MoveDirection.
Disabling controls through the player’s PlayerModule, this nullifies Humanoid.MoveDirection.
I’m sorry if this post is sloppy in any way, this is my first time posting here.
This can be accomplished through modifying the default PlayerModule. This is my implementation, but all you really need to do is replace the controller’s moveFunction with your own that does nothing and grab the walkDirection argument.
If you’d like to use my code, paste it into a LocalScript and put it under StarterPlayerScripts.
local PlayerModule = require(script.Parent:WaitForChild('PlayerModule'))
local controls = PlayerModule.controls -- Grab the ControlModule
local enabled = true
local oldMove = controls.moveFunction -- Grab old moveFunction that will be replaced
function controls.moveFunction ( self: Player, walkDirection: Vector3, relativeToCamera: boolean? )
if ( enabled == false ) then
return oldMove(self, Vector3.zero, relativeToCamera) -- Don't move at all
end
return oldMove(self, walkDirection, relativeToCamera) -- Move like normal
end
local humanoid = controls.humanoid -- Get character humanoid
while true do
-- Alternate between enabling and disabling the default controller
if ( math.floor(tick()) % 2 == 0 ) then
enabled = false
else
enabled = true
end
print('Humanoid.MoveDirection: ', controls.humanoid and controls.humanoid.MoveDirection) -- Humanoid.MoveDirection flips between an empty vector and the correct input vector
print('MoveVector', PlayerModule.controls.inputMoveVector) -- the inputMoveVector keeps the input value even when not moving
task.wait(0.1)
end