As you can see he has his head connected to this cyan ball
Which means he should move his head like this:
But instead he completely ignores the attachment and moves it like its in the center
Here’s the script:
game:GetService('RunService').Heartbeat:Connect(function(delta)
local Plr,Char = GetNearestPlayer(Torso.Position, math.huge)
if Plr then
if Char then
Neck.C0 = Neck.Part0.CFrame:Inverse()*CFrame.lookAt(Neck.Part1.Position, Char.Head.Position) * Neck.C1
end
end
end)
local HumanoidRootPart = -- hrp of npc
Neck.C0 = HumanoidRootPart:ToObjectSpace(CFrame.new(HumanoidRootPart.Position,Char.Head.Position))*NeckC0Offset -- the base neck c0 offset
whenever i modify motor6d’s i usually do something like this, maybe it’ll work
local target:BasePart
local npc:Model
local head:BasePart=npc.Head
local motor:Motor6D=npc.Torso.Neck
local originalC0:CFrame=motor.C0
game:GetService("RunService").Heartbeat:Connect(function()
motor.C0=motor.C0:Lerp(originalC0*CFrame.new(head.Position,target.Poistion),1)
end)
it usually works for me. Putting it in a lerp just helps if you want to ease the head turning.
if it doesn’t work try removing the new cframes position
local cframeTo=CFrame.new(head.Position,target.Position)
cframeTo-=cframeTo.Position