Children is an array of Resource objects so $item is a Resource Object. Your problem is the $values = line and the line after it. It's setting the 'id' to an object rather than an integer and trying to use that as an ID in the getObject() call. Also, you don't need to get the child resource with getObject() -- you already have it.
I assume you're setting $group somewhere earlier.
Try this:
$c = $modx->newQuery('modResource');
$output = '';
$c->sortby('RAND()');
$c->limit(3);
$doc = $modx->getObject('modResource', 5);
if ($doc) {
$children = $doc->getMany('Children', $c);
foreach($children as $item) {
$list = $item->getTVValue('directoryInclude');
if (strpos($list, $group)) {
$output .= $modx->parseChunk('specificList', $values, '[+', '+]');
}
}
} else {
$output = 'Resource 5 not found';
}
return $output;
BTW, if you're using Revolution, the placeholders in the chunk would normally be in this form, in which case you wouldn't need the prefix and suffix and things would be a little faster:
The line would then be:
$output .= $modx->getChunk('specificList', $values);
If you're not using Revolution, none of this is going to work.