The model is an NPC that needs to rotate/face a second NPC's position when the second NPC touches the first.

I've used this code down below, but it isn't entirely accurate and makes the model spin.

local model = script.Parent.Parent.Parent
script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Name == "NPC"  then
		local position = model.HumanoidRootPart.CFrame
		local torso = hit.Parent.Torso
		model:SetPrimaryPartCFrame(position * (torso.CFrame - torso.Position))
	end
end)

Any help is appreciated.

4 comments

0

use for i,v in pairs(getchildren()) do

1

I've discovered this a few months back, and it should help. https://developer.roblox.com/api-reference/class/AlignOrientation

0

this is another helpful link regarding AlignOrientation https://devforum.roblox.com/t/new-body-movers/33652