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.
Code:
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild(“HumanoidRootPart”)
if neck then
local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
neck.C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, -camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0)
end
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