How can I move Player game object with touch input only on x axis?

So I just started to work with Unity, I am good at everything like : graphics design(UI), 3d modeling, and so on, but I am new to programming and don’t really know much yet. How can I move the player with touch on x axis like if I was dragign the player with my finger? I only found this piece of code on forums, how can I use it, is it even the correct one? And can some one please tell me were could I find some easy, fast step-by-step unity(C#) Coding/undestanding tutorials. Thanks!

    var speed : float = 0.1;
    function Update () {
    if (Input.touchCount > 0
    Input.GetTouch(0).phase == TouchPhase.Moved) {
    
    var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
    
    transform.Translate (-touchDeltaPosition.x * speed,
    -touchDeltaPosition.y * speed, 0);
    }
    }

Don’t use touchDeltaPosition.y.

The code gets the first touch position, and sees if that position moves, then collects the amount of movement from last frame to this frame, then moves a transform that amount.

So it is correct.

transform.Translate (-touchDeltaPosition.x * speed, 0, 0);