A moving walker vehicle

I am attempting to make a walker vehicles for my upcoming game. The player should be able to sit down in the driver seat and drive the walker around on the walker’s local axis with :VectorToWorldSpace() so that it works like a normal Roblox vehicle. I have added this script to the walker seat so that when sat down it puts it into the players’ character and allows them to move, the only problem is that when the player presses a movement key it doesn’t move at all. Not sure why as I don’t receive any errors from the output. Can someone please identify the problem in this script and suggest or tell me how to fix it? It would be much appreciated. ATRT is just the vehicle’s humanoid component fired from the sit detector script.

game.ReplicatedStorage.vehicleATRT.OnClientEvent:Connect(function(ATRT)

Humanoid = ATRT

end)

--// Dependencies

local ContextActionService = game:GetService("ContextActionService")

--// Variables

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(0,0,-1), End = Vector3.new(0,0,1)};

D = {Begin = Vector3.new(0,0,1), End = Vector3.new(0,0,-1)};

}

--// Functions

local function handleInput(name, state, input)

local keyCode = input.KeyCode

local moveDirection = Humanoid.Parent.Torso.CFrame:VectorToWorldSpace()

Humanoid.Parent.Torso.CFrame:VectorToWorldSpace(moveDirection + DirectionIncrements[keyCode.Name][state.Name])

print(Humanoid.Parent.Torso.CFrame)

end

--// Binds

ContextActionService:BindActionAtPriority("CustomMovement", handleInput, Enum.ContextActionPriority.High.Value, false, unpack(DirectionInputs))

ThanksRoBama I remember you recommending me VectorToWorldSpace() to make the walker move on the vehicles local axis, did I implement this incorrectly?

That’s an almost.
You are using :VectorToWorldSpace() wrong in assuming that it’s a setter. It doesn’t do anything other than return a converted world space point from its previous Vector format.

You’ll want to take that data and apply it to a bodymover, or even better a new LineForce/VectorForce. Or you could just set the torso’s cframe/position to this new world coordinate.

This:

Humanoid.Parent.Torso.CFrame:VectorToWorldSpace(moveDirection + DirectionIncrements[keyCode.Name][state.Name])

is not doing anything.

The plan for moving the vehicle is through making the humanoid move so that it does a walk animation on its own without doing any complicated work with CFrame, could there be a way to instead use this but so that it moves the humanoid on the vehicles axis not the worlds?:
Humanoid:Move(moveDirection + DirectionIncrements[keyCode.Name][state.Name])
I used this before but it moved the vehicle on the worlds axis.

LookVector’s are my method of just moving past world or local axis. They tell the script where the part is facing, and therefore can help position the part.

part.CFrame.LookVector -- this is a unit vector BTW

I know which direction the vehicle is going but now how to make it go that way on its local axis, couldn’t I just use Humanoid:Move(part.CFrame.new(moveDirection + DirectionIncrements[keyCode.Name][state.Name]))

I believe it would be Humanoid:MoveTo() instead.