Player doesn't move when Camera follow player


I set camera to follow player only x axis
but when I set camera, player stopped moving
(but there is a change in the x-axis)

Here’s my player movement code & camera follow code

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

public class CameraMove : MonoBehaviour
{

public Transform target;
    // Update is called once per frame
    void Update()
    {
        transform.position = new Vector3(target.position.x, transform.position.y,-10);
    }
}

Isn’t this just a duplicate of: Camera follow x axis ?

Also, if you’re asking general scripting questions then you should ask on the Scripting forum.

If you are asking about the UI/Canvas etc then you can use the UGUI forum.

Moved.