Always Keep player at postiosion.y = 0?

Ok sO i managed to get my player to not go outside the screen but when you go to the edge of the screen you go Up, but stay inside the screen, was wondering how I can keep my transform.position.y always at 0
So this Dose Not happen

error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable

(I already have the RidgedBody set to Y, but it is still happening.)

public Vector3 moveDirection;
	public CharacterController PlayerControll;
	public float moveSpeed = 10;
	public float YZero = 0;
	public float GravityScale;
	public GameObject Spawnpoint;

	// Use this for initialization
	void Start () {
		Spawnpoint = GameObject.FindGameObjectWithTag ("SpawnPlayer");
		transform.position = Spawnpoint.transform.position;
	}
	
	// Update is called once per frame
	void Update () {

		transform.position.y  = YZero;

		moveDirection = new Vector3 (Input.GetAxis ("Horizontal") * moveSpeed, 0f, Input.GetAxis ("Vertical") * moveSpeed);
		moveDirection.y = moveDirection.y + (Physics.gravity.y * GravityScale);
		PlayerControll.Move (moveDirection * Time.deltaTime);

		Vector3 pos = Camera.main.WorldToViewportPoint (transform.position);
		pos.x = Mathf.Clamp01(pos.x);
		pos.y = Mathf.Clamp01(pos.y);
		transform.position = Camera.main.ViewportToWorldPoint(pos);
	}
}

The error you are receiving also explains how to fix it (although I understand why it is not obvious when you read it). Consider to store it in a temporary variable:

Vector3 pos = transform.position;
pos.y = 0;
transform.position = pos;

This is because the position variable has a getter and a setter, which means it can only be modified as a whole, but not partially. The best place for this code would be FixedUpdate though, not Update (since FixedUpdate is not framerate dependent).

Line 17,

transform.position.y  = YZero;

That is where your error comes from.
You cannot directly assign a single axis for transform.position.

try this in replacement for line 26

pos = Camera.main.ViewportToWorldPoint(pos);
pos.y = 0f;

transform.position = pos;