Moving a humanoid on their local axis

I don’t want to know any alternatives like body forces as they wont be moving the vehicle character as I want, just tell me please, please. How do I move a humanoid on their own local axis. This is the control script, but it moves the humanoid on the worlds axis:

local Humanoid = script.Parent.Humanoid
local DirectionInputs = {Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D}
local DirectionIncrements = {
	W = {Begin = Vector3.new(-1,0,0), End = Vector3.new(1,0,0)};
	A = {Begin = Vector3.new(1,0,0), End = Vector3.new(-1,0,0)};
	S = {Begin = Vector3.new(-1,0,0), End = Vector3.new(1,0,0)};
	D = {Begin = Vector3.new(1,0,0), End = Vector3.new(-1,0,0)};
}
local function handleInput(name, state, input)
	local keyCode = input.KeyCode
	local moveDirection = Humanoid.MoveDirection

	Humanoid:Move(moveDirection + DirectionIncrements[keyCode.Name][state.Name])
	print(Humanoid.MoveDirection)
end

Someone please give me an answer or suggestion or help.

1 Like

Do you mean relative to the camera? The Humanoid.Move method accepts a second parameter as a bool, which is whether the movement direction should be relative to the camera.

Therefore you can call
Humanoid:Move(moveDirection + DirectionIncrements[keyCode.Name][state.Name], true)

The humanoid Im attempting to move is a custom rigged vehicle such as a mech, I want the player to be able to drive it but on its local axis, so that it acts as an actual vehicle.

Find the direction you’re facing, then apply the intended distance gained. The vector between start->end is your movement.

You can You using vectorToObjectSpace:

Humanoid:Move(Humanoid.RootPart.CFrame:vectorToObjectSpace(moveDirection + DirectionIncrements[keyCode.Name][state.Name]))