How can I make my character go toward my look vector? (Closed)

Hello,
I’m trying to make my character walk forward toward the character’s look vector. How can I do this? Currently it’s going at the same direction. So how can I fix this?
Here’s the script:

local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")

local moveValue = 0

local function onMove(actionName, inputState)
   if inputState == Enum.UserInputState.Begin then
      moveValue = 1
   elseif inputState == Enum.UserInputState.End then
      moveValue = 0
   end
end

local function onUpdate()

   if player.Character and player.Character:FindFirstChild("Humanoid") then

      player.Character.Humanoid:Move(Vector3.new(moveValue,0,moveValue), true)

   end

end

RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)

ContextActionService:BindAction("Move", onMove, true, Enum.KeyCode.W, Enum.KeyCode.Up, Enum.KeyCode.DPadUp)

Thank you for reading.

try using the camera’s lookvector. Actually im not even sure where you’re using the lookvector property? Are you not showing the full code?

Did you read any other posts, I believe it’s been answered in here: Making the player face the mouse, how should I go about it?

What is that? I’ve never really done this before…

oh i see, what exactly are you trying to accomplish here?

i dont think thats what they are trying to do

So I have a system that you can only move forward, but I still need to be able to aim or else it will just keep going straight so I need it so I can turn sort of? Like shift lock. I might be offline for a while so sorry. Something unexcpetected happened

so you want the player character to always face the same direction as their camera is looking? If so then there is a much easier way to go about that using the default roblox stuff. Let me know when you get back.

If you have more than just this script you might need to explain to us how your system functions so we can get a better picture of how it works

I don’t understand. Does he want the player to face the mouse?

1 Like

I think they want something like shiftlock but im not sure because they are a beginner and might not know how to explain it.

Are you trying to make the player automatically walk in the direction they’re facing?

Change the HumanoidRootPart’s CFrame value to that of the look Vector3 value.

Here’s a video
robloxapp-20211102-1753303.wmv (349.1 KB)
As you can see I can only go one way even though my look vector is the other way.

It’s basically the same default controls, but you can only move forward toward your look vector is what I’m trying to do. Sorry for the poor explanation.

This doesn’t move my character. Here’s the updated line
player.Character.Humanoid:Move(Vector3.new(player.Character.HumanoidRootPart.CFrame), false)

I found the solution thank you for everyone who helped. :smiley: