Translate on xaxis a certain distance then back and keep repeating

I’m new to scripting and I want to write a script that has a game object moving continuously back and forth over a set distance. Basically I need the game object to move left and right continuously.

Ok… and what’s the problem? What have you tried? Did you look at Mathf.PingPong?

void Update() {
    transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);