Making an NPC face the player by changing RootJoint C0

i do have a question, did u write also this piece of line?

Character.PrimaryPart:SetNetworkOwner(nil)

No I didn’t, what does the line do?

well on a few chase scripts i usually saw this line being put, heres a more clear documentation on it

it does something with lag or i dont really know… i also need to have a better research on it
it might not be needed but i just wanted to point this out

edit: i also found this post (might not match ur solution):

also one more thing in ur case, which u want the enemy to look at the target even if its far away, you’d probally have to do something like raycasting, or just check if the distances are too far and then make the enemy lookat the target and then, just chase it

(i am still not clear, of what you want)

So I found a way to ALMOST fix it, I’m just stuck at what I think should be the final part. I’ve made the rotate towards a certain point by offsetting the C0. However I’ve ran into another issue, if the character model’s rotation is not 0,0,0 then it will be offset by the Y value of the model’s rotation. Any ideas on how I can fix this?

My code:

    script.Parent.HumanoidRootPart.RootJoint.C0 = CFrame.new(Vector3.new(0,0,0),CFrame.lookAt(Pos.Position,Vector3.new(Target.X,Pos.Position.Y,Target.Z)).LookVector)
	script.Parent.HumanoidRootPart.RootJoint.C1 = CFrame.new(Vector3.new(0,0,0),Vector3.new(0,0,0))

Okay nevermind I fixed it myself, here’s the code for those who may run into the same issue:

    script.Parent.HumanoidRootPart.RootJoint.C0 = CFrame.new(Vector3.new(0,0,0),CFrame.lookAt(Pos.Position,Vector3.new(Target.X,Pos.Position.Y,Target.Z)).LookVector)*CFrame.Angles(math.rad(Rot.X),math.rad(Rot.Y),math.rad(Rot.Z)):Inverse()
	script.Parent.HumanoidRootPart.RootJoint.C1 = CFrame.new(Vector3.new(0,0,0),Vector3.new(0,0,0))

Rot is rotation of primary part
Pos is CFrame of primary part
Target is where you want character to look

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.