Moving GameObject a specific distance in the Z direction and back again - regardless of rotation

Hello -

I am a beginner and working on my first 3D game.

I need to be able to programmatically move a GameObject in its forward direction a certain distance, determine when it reaches that distance, and then return it back to its starting point.

I can make this work using Vector3.MoveTowards and Transform.Forward - the problem I face is that the GameObject could be at a different rotation everytime the game is played as it is dynamically created in the environment based on where a user taps.

So I need to move forward the direction it is facing at runtime and back again regardless of rotation.

I am using C#

I appreciate any help!

Your looking for transform.translate(Vector3.Forward,space.World);