Problems with Mathf.PingPong

Originally, I was using the ScriptReference for Mathf.PingPong, but unfortunately, it would automatically move the object so that it’s Z value would be 0. How can I prevent this so that the object will PingPong from its current position? Here’s the ScriptReference for Mathf.PingPong:

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

Try the following:

void Update()
{
	Vector3 pos = transform.position;
	pos.x = Mathf.PingPong(Time.time, 3);
	transform.position = pos;
}