--- RUNTIME ---


while true do
    -- Get closest character head
    ClosestHead = nil
	ClosestDistance = MaxDistance
	CharacterHeads = {}
	for _, Character in pairs(workspace.Characters:GetChildren()) do
		if Character:IsA("Model") and Character:FindFirstChild("Head") then
			table.insert(CharacterHeads, Character.Head)
		end
	end
	
	for _, Head in pairs(CharacterHeads) do
		Distance = (Head.Position - NPCHead.Position).Magnitude
		
		if Distance < ClosestDistance then
			ClosestDistance = Distance
			ClosestHead = Head
		end	
	end
    
    -- Look at closest character head or reset to original position if none found 
	if ClosestHead ~= nil then        
		-- Look at
		TweenService:Create(NPCHead, TweenInfo.new(0.5), {CFrame=lookAt(NPCHead.Position, ClosestHead.Position)}):Play()
    else 
		TweenService:Create(NPCHead, TweenInfo.new(0.5), {CFrame=OriginalHeadCF}):Play()
    end
    
	wait()    
end
