ERROR :
"Attempt to call a nil value"
I want my "Head" to cframe to my mouse (Like daxter33's head rotation)
Where you move your mouse your head stays on your character, but it will rotate to your mouse.
function SetHeadPos(Pos)
if not Pos then return end
local run,error = ypcall(function()
local Weld = Instance.new("Weld")
Weld.Part0 = Char.Torso
Weld.Part1 = Char["Head"]
Weld.C0 = CFrame.new(0, 1.4, 0)
Weld.Parent = Weld.Part0
pcall(function()
for _,v in pairs(Char.Head:GetChildren()) do
if v.ClassName=='SpecialMesh' then
v:remove()
end
end
end)
if Char:findFirstChild('Head') then
pcall(function()
for _,v in pairs(Char:GetChildren()) do
if v.ClassName == 'Hat' then
v:remove()
end
end
local jointPosition = Weld.Part0.CFrame:toWorldSpace(CFrame.new(1, 0.5, 0))
local cframe = CFrame.new(jointPosition.p, Pos) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -1, 0)
Weld.C0 = Weld.Part0.CFrame:toObjectSpace(cframe)
end)
end
end)
if not run then end
end
Run.Heartbeat:connect(SetHeadPos(Plr:GetMouse().Hit.p))
