How can I improve on this code?

Hey, I was wondering if anyone knows any ways I can improve on this code that is meant to make the players head follow the camera movement. I will appreciate every bit of help.

local cam = workspace.CurrentCamera

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild(“HumanoidRootPart”)

local neck = char:FindFirstChild(“Neck”, true)

local y = neck.C0.Y


if neck then
    local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
    neck.C0 =, y, 0) * CFrame.Angles(0, -camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0)
1 Like

What? I don’t understand what that’s suppose to mean

1 Like

Well this will only work until the character dies.
You only set ‘char’ and ‘neck’ once, so when a character dies and a new one is loaded, you’re not using the right ‘neck’ in your calculations

1 Like

I’m a bit confused here, so if I set it so the player isn’t able to reset it will work?

1 Like
local char, humanoidRoot, neck
plr.CharacterAdded:Connect(function (character)
    neck = character:FindFirstChild('Neck', true)