How to make the HumanoidRootPart point towards the camera?

I’m making my custom POV mechanic for the player, so I turned ‘AutoRotate’ off.

I would like to know how I could get the HumanoidRootPart to point in the direction of the mouse. I’m not the best with CFrames.

Anyone have any ideas?

1 Like

The easiest way would be to use the (pos, lookAt)-constructor

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
local mouse = plr:GetMouse()


local function onRenderStep()
    local char = plr.Character
    if not char then
        return
    end
    local hrp = char:FindFirstChild("HumanoidRootPart")
    if not hrp then
        return
    end
    local hrpPos = hrp.Position
    local dir = mouse.Hit.Position-hrpPos
    dir = Vector3.new(dir.X, 0, dir.Z)
    hrp.CFrame = CFrame.new(hrpPos, hrpPos+dir)
end

RunService.RenderStepped:Connect(onRenderStep)

That code only makes it rotate horizontally. If you want it to be able to rotate on any axis, remove this line:

dir = Vector3.new(dir.X, 0, dir.Z)
4 Likes