So I've tried to simply set humanoidRootPart.Orientation = Vector3.new(0, 180, 0)
as a test to see if it would keep facing one direction at all times.
That's not what ended up happening at all. The character went spinning all over the place. Just to see what's going on, I set the transparency of the humanoid root part to zero. This is what it looked like. I'm not sure what happened there but it seemed like the character actually separated from the humanoid root part? (although the root part seemed to be always facing one direction)
I've heard that you can use BodyGyro or AlignOrientation, but even after reading the wiki pages of both, I'm stumped on how to use these to change my character's orientation.
Well, the mouse's lookVector is constantly changing, so just setting the Orientation of the player's HumanoidRootPart will not keep them in sync. Instead, you can try this
First, to check how much the player's mouse will affect movement (higher numbers will make you spin too much), you set _G.MouseSensitivity to 0 (changing this value will make the camera move with the mouse)
Next, we have a few functions to make the mouse move with the camera when not set to 0
Then you will need to check the hit.p of the mouse for the player to move with it (as seen in the Mouse.Move Event)
This LocalScript will move the player to match the mouse, along with some functions to change the camera
_G.MouseSensitivity = 0 _G.MouseSensitivityOffset = 0 local Player = game.Players.LocalPlayer local Camera = workspace.CurrentCamera local Mouse = Player:GetMouse() function RotateCamera(x, y) Camera.CoordinateFrame = CFrame.new(Camera.Focus.p) * (Camera.CoordinateFrame - Camera.CoordinateFrame.p) * CFrame.Angles(x, y, 0) * CFrame.new(0, 0, (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude) end function GetAngles(cf) local lv = cf.lookVector return -math.asin(lv.y), math.atan2(lv.x, -lv.z) end local LastCF = Camera.CoordinateFrame function UpdateSensitivity() if _G.MouseSensitivity ~= 1 then -- no need to do this if it's 1 local x, y = GetAngles(LastCF:toObjectSpace(Camera.CoordinateFrame)) Camera.CoordinateFrame = LastCF RotateCamera(x * -(_G.MouseSensitivity + _G.MouseSensitivityOffset), y * -(_G.MouseSensitivity + _G.MouseSensitivityOffset)) LastCF = Camera.CoordinateFrame end end Mouse.Move:connect(function() UpdateSensitivity() local root = Player.Character.HumanoidRootPart Player.Character:SetPrimaryPartCFrame(CFrame.new(root.Position, (Mouse.Hit.lookVector*Vector3.new(1,0,1)) + (root.Position*Vector3.new(0, 1, 0)))) end) Mouse.Idle:connect(function() LastCF = Camera.CoordinateFrame end)
You can change "lookVector" to "p" if you want the player to rotate with the mouse as well I will also note that the "lookVector" doesnt not function properly if the player begins to move, so using "p" is probably the preferred method.
Also, if you don't need to deal with the camera, then only this section is required
_G.MouseSensitivity = 0 _G.MouseSensitivityOffset = 0 local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.Move:connect(function() local root = Player.Character.HumanoidRootPart Player.Character:SetPrimaryPartCFrame(CFrame.new(root.Position, (Mouse.Hit.lookVector*Vector3.new(1,0,1)) + (root.Position*Vector3.new(0, 1, 0)))) end)