Ristricting child translation to single axis Object A is the parent of object B. How can I restrict the translation of object B to the X-axis, when object A is translated randomly (along the X-, Y- and Z-axis)?

I tried locking the Y- and Z-axis for Object B, but that doesn't seem to work.
Use a child of constraint on B, set the Target to A and select only Location X.

A's location on the X axis will affect B, all other transformations will not.