I want to teleport my player to a random(from these 4) spot on the x axis, but it doesn't work.

private float x = {-8, -4, 4, 8};
private float y = 1;
private float z = 0;

    Vector3 NewPos;

 void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Door"))
        {
            Vector3 tempPos = transform.position;

            int mynum = Random.Range(0, x.Length);
            NewPos = new Vector3(x[mynum], y, z);

            tempPos.x = NewPos.x;
            tempPos.y = NewPos.y;
            tempPos.z = NewPos.z;
}

Hi, you only stored the value in a variable but that doesn’t affect your player position.
Use this instead:

int mynum = Random.Range(0, x.Length);
NewPos = new Vector3(x[mynum], y, z);
 
transform.position = NewPos;