Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a character's head follow the mouse's position?

Asked by 3 years ago

Okay, so I'm trying to make a local script which makes the character's head follow the mouse. This is going to be used in first person so I'm just trying to make it rotate up and down to follow the mouse looking up and down. This is wrote for a character in R6.

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

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

plr.CharacterAdded:Connect(function(char)
    local hum, hrp = char:WaitForChild("Humanoid"), char:WaitForChild("Head")
    while char.Parent and hum.Health > 0 do
        local mouseHit = mouse.Hit
        local hrpPos = hrp.Position
        hrp.CFrame = CFrame.new(hrpPos, mouseHit.Position) 
        RunService.RenderStepped:Wait()
    end
end)

This follows the mouse but the whole body follows the mouse instead of the head. Thank you for your time. - Zeta

Answer this question