No coding experience, tried to mash two codes together, but they aren't playing nicely

So the idea is to get the cube i’m currently using to move 1.25 right and -1.25 left which I fixed in its code, and the other one uses touch in order to move the character, but after trying to export an .apk it doesn’t seem to work. Would really appreciate some help! Attached is the whole code I’m using:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
    //variables
    public GameObject character;
    private float speed = 5.0f;
    private Vector3 pos;
    private Transform tr;
    private Rigidbody2D characterBody;
    private float ScreenWidth;


    // Use this for initialization
    void Start()
    {
        pos = transform.position;
        tr = transform;
        ScreenWidth = Screen.width;
        characterBody = character.GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        int i = 0;
        //loop over every touch found
        while (i < Input.touchCount)
        {
            if (Input.GetTouch(i).position.x > ScreenWidth / 2 && tr.position == pos)
            {
                //move right
                pos += new Vector3(1.25f, 0, 0);
            }
            if (Input.GetTouch(i).position.x < ScreenWidth / 2 && tr.position == pos)
            {
                //move left
                pos += new Vector3(-1.25f, 0, 0);
            }
            ++i;
        }
    }
}

Good day.

You say when yo uexport does not work, but, it works in the editor?

I did not read all the code, dont know what you want to get, and never did a project for mobile, so Input.touch family functions are a mistery for me. But, if you read the manual will see some incongruences

[....]
void Update()
     {
         int i = 0;
         //loop over every touch found
         while (i < Input.touchCount)
 [....]

If you read the Input.touchCount manual the only it says is:

Number of touches. Guaranteed not to change throughout the frame. (Read Only)

So, if Update is called only once per frame, the value of touchCount will be always the same during that frame.

It can be this? Did you debuged the code to see how the number increases?

Bye!