Touch right/left side of screen? Javascript

Hello!
I want to create a simple script that allows the user to walk to the left if the left side of the screen is touched, and ofcourse walk to the right if the right side is touched.
I would think my solution should work but it doesn’t move like he should.
I know my touchscript worked because I tried it out using another plane that you can touch to move.

Right now regardless of where I touch the screen, it will walk to the left, if I try to change the hit.point.x to greater or less than, it will just do the same but opposite.

Am I doing this wrong or why is this happening?
Ps. I’m trying it on an iphone.

here’s the script:

#pragma strict

var MovementSpeed: float;


function Start() {
    MovementSpeed = 10f;
}

function Update() {
    if (Input.touchCount > 0) {
        var ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
        var hit: RaycastHit;
        if (Physics.Raycast(ray, hit)) {
            if (hit.point.x > Screen.width / 2) {
                transform.Translate(Vector2.right * Time.deltaTime * MovementSpeed);
            }
            if (hit.point.x < Screen.width / 2) {
                transform.Translate(Vector2.right * Time.deltaTime * MovementSpeed * -1);
            }
        }
    }
}

You don’t need any raycasting; just look at touch.position.x, and if the value is small enough then it’s on the left side, and if it’s large enough it’s on the right side. How small/large depends on Screen.width.

–Eric

Did you ever fix this? I’m trying the same on my iPhone screen but they always move to the left and not the right