How to fix “Object of class WP_Term could not be converted to string”?

According to the docs for the Term object the ID is in the property term_id So you need:

    $ids = array();

    foreach ($taxonomy as $tax) {
        $ids[] = $tax->term_id;
    }

    $joinedIds = implode(" ", $ids);

    // do something with $joinedIds;