Getmousebutton not working,getmousebuttton not working

So i am currently working on a mobile game and i am making a hyper casual game.
i have wrote the code perfectly but i am not getting desired output of moving player right and left. so can anyone tell where i have gone wrong. the code is provided below…

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
[SerializeField] private Transform playerTransform;
[SerializeField] private float limitValue;

private void update()
{
    if(Input.GetMouseButton(0))
    {
        MovePlayer();
    }
}

private void MovePlayer()
{
    //calculate x position and move it there...
    float halfScreen = Screen.width / 2;
    float xPos = (Input.mousePosition.x - halfScreen) / halfScreen;
    float finalXPos = Mathf.Clamp (xPos * limitValue, -limitValue, limitValue);

    playerTransform.localPosition = new Vector3(finalXPos, 0, 0);
}

}

Please if anyone know the alternative of the function plz reply
thanks ,So i was making a hyper casual game i wrote the code perfectly yet i am not getting desired output to move the character left and write. its a mobile game.
The code is given below

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
[SerializeField] private Transform playerTransform;
[SerializeField] private float limitValue;

private void update()
{
    if(Input.GetMouseButton(0))
    {
        MovePlayer();
    }
}

private void MovePlayer()
{
    //calculate x position and move it there...
    float halfScreen = Screen.width / 2;
    float xPos = (Input.mousePosition.x - halfScreen) / halfScreen;
    float finalXPos = Mathf.Clamp (xPos * limitValue, -limitValue, limitValue);

    playerTransform.localPosition = new Vector3(finalXPos, 0, 0);
}

}

I am not sure I fully understand the question, but I think you just want to move player to where your mouse is right? Why don’t you just do Camera.main.ScreenToWorldPoint.

private void Update()
    {
        if (Input.GetMouseButton(0))
        {
            Player.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, zPosition));
        }
    }

With this it will check every frame “Update()” if player is clicking LMB/or clicking screen “(Input.GetMouseButton(0))”, and if they are move them to location that you clicked. The thing about this is it teleports the player (I am unsure whether you want this, didn’t fully understand your question) and if you don’t want that you could just make player use MoveToward on an empty gameobject, although with this after you click the gameobject will stay where you last clicked so yet again im not sure if that will work for what you want.