How can I use clicked position for an object and camera movement at he same time?

Hi everyone.

How can I use these codes when camera is moving? Because I clicked the any button which has the script and then clicked somewhere object is moving where I clicked, but camera is not working anyhow anymore.

public void SetTargetPosition()
{

    if (Input.GetMouseButton(0))
    {
        
        cubes.SetActive(true);
        if (EventSystem.current.IsPointerOverGameObject()) return;

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        Vector3 clickPosition = -Vector3.one;

        if (Physics.Raycast(ray, out hit, 1000))
        {

                float cubeYScale = cubes.transform.localScale.z*0.12665f;
                clickPosition = hit.point;
                clickPosition.y = (clickPosition.y) + (cubeYScale);
                cubes.transform.position = Vector3.Lerp(cubes.transform.position, clickPosition, 0.1f);
                
                Time.timeScale = 0;
           
        }

    }
    
}

Camera movement codes like this:
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
newPosition += (transform.forward * movementSpeed);
}
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
newPosition += (transform.forward * -movementSpeed);
}
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
newPosition += (transform.right * movementSpeed);
}
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
newPosition += (transform.right * -movementSpeed);
}

Thanks for reply.

Go here Sebastian Lague - YouTube I believe that he has a tutorial on the movement you’re asking about.