changing velocity than changing position

Hello,

if my objects y is less or more than 1 ,-1 than i want to zero the velocity of y and reset its position on y so here is my code but for some reason it gives error and object just keeps going when i disable the reset position. I get those errors and some more just like those, thanks in advance.

Assets/Scripts/resetpos.cs(20,68): error CS1061: Type UnityEngine.Transform' does not contain a definition for x’ and no extension method x' of type UnityEngine.Transform’ could be found (are you missing a using directive or an assembly reference?)

Assets/Scripts/resetpos.cs(20,82): error CS1061: Type UnityEngine.Transform' does not contain a definition for z’ and no extension method z' of type UnityEngine.Transform’ could be found (are you missing a using directive or an assembly reference?)
Assets/Scripts/resetpos.cs(24,68): error CS1061: Type UnityEngine.Transform' does not contain a definition for x’ and no extension method x' of type UnityEngine.Transform’ could be found (are you missing a using directive or an assembly reference?)

public class resetpos : MonoBehaviour {

	// Use this for initialization


	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {



		if (transform.position.y < -1) {
			GetComponent<Rigidbody>().velocity = new Vector3 (GetComponent<Rigidbody>().velocity.x, 0, GetComponent<Rigidbody>().velocity.z);
			transform.position= new Vector3 (transform.x,0,transform.z);
		}
		if (transform.position.y > 1) {
			GetComponent<Rigidbody>().velocity = new Vector3 (GetComponent<Rigidbody>().velocity.x, 0, GetComponent<Rigidbody>().velocity.z);
			transform.position= new Vector3 (transform.x,0,transform.z);

		}




}
}

Try transform.position.x and transform.position.z instead of just transform.x.
So your code would then look like this.

public class resetpos : MonoBehaviour {
 
     // Use this for initialization
 
 
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
 
 
 
         if (transform.position.y < -1) {
             GetComponent<Rigidbody>().velocity = new Vector3 (GetComponent<Rigidbody>().velocity.x, 0, GetComponent<Rigidbody>().velocity.z);
             transform.position = new Vector3 (transform.position.x,0,transform.position.z);
         }
         if (transform.position.y > 1) {
             GetComponent<Rigidbody>().velocity = new Vector3 (GetComponent<Rigidbody>().velocity.x, 0, GetComponent<Rigidbody>().velocity.z);
             transform.position = new Vector3 (transform.position.x,0,transform.position.z);
 
         }
 
 
 
 
 }
 }