Just be aware that that won't work if the TV is set to its default value (there won't be a modTemplateVarResource object), or if it's a TV that needs rendering (e.g., @ bindings, image TV's, etc.).
BTW, this will do the same thing as the code above, but will be slightly quicker and use less memory because it doesn't retrieve the object, just the field value:
$query = $modx->newQuery('modTemplateVarResource', array(
'contentid' => $resourceId,
'tmplvarid' => $tvId,
));
$query->select('value');
return $modx->getValue($query->prepare());