Moving an object between two positions (C#)

my objective is to put an object such as a cube at an origin position, have it move to a set destination position, and once it reaches the destination point, have it move back to the origin point.

I’ve tried for hours creating a script with an if statement along the lines of: “if the object’s position is equal to this set position, then switch the direction of which the object is headed” to no avail. I tried finding a way to store position A and position B as preset positions, but couldn’t find a variable to store it in.

Is there supposed to be a simpler way to achieve a moving platform script, or is there a way to store positions as variables?

Don’t try to check for positions; use Lerp. You can store positions in a Vector3.