Player not moving forward properly

so, Im trying to make a system where the player will turn based on the mouse position. That works fine, but whenever I try to walk, the directions of moving are completely messed up. Anyone know how to fix this?

I expect that the character wil move in the direction that it’s facing when I press W.

Code:

local player = game.Players.LocalPlayer
local character = player.Character

local mouse = player:GetMouse()
local camera = workspace.CurrentCamera



game:GetService("RunService").RenderStepped:Connect(function()
    local forwardVector = (character.HumanoidRootPart.Position - mouse.hit.Position).Unit
    local rightVector = forwardVector:Cross(Vector3.new(0,1,0))
    local cframe = CFrame.fromMatrix(character.HumanoidRootPart.Position, -rightVector, Vector3.new(0, 1, 0))
	
	character.HumanoidRootPart.CFrame = cframe
end)

By default its relative to camera.

You will need a custom movement script like below to change it:

1 Like

where do I put the script if I may ask?

okay nvm it’s working perfectly now! Thank you @dthecoolest there’s a reason why i always looked up to you lol. Thanks for the help

1 Like