VR - How to grab object and move it only in Z axis

Depending on what you want to do, you could forgo the attachment altogether and just set its location directly while the button or trigger is held. So something like this pseudocode:

if (ViveController.Trigger.isheld)
{
    Object.SetActorLocation(Object.GetActorLocation().x, Object.GetActorLocation().y, ViveController.GetActorLocation().z)
}

This way its x and y never change, just the z, being the same as the controller’s z.