Why doesn't my camera lock to the player's position?,

Hello, I’m pretty new to unity and I don’t know why this is happening but I’ve written this code that is meant to lock the camera’s position to the player, but it just doesn’t work.
185408-m.gif

As you can see in this gif, the cube just falls and the camera does not move to the cube’s current position.
I could simply just drag and drop the camera into the cube, but the problems with that is when the cube rotates when either jumping on an edge, which I want but the camera rotates as well.
Here’s the code, by the way the Main transform is set to the player’s transform.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraScript : MonoBehaviour
{
    public Transform Main;
    private Camera camera;

    void Start()
    {
        camera = GetComponent<Camera>();
    }

    void LastUpdate()
    {
        camera.transform.position = new Vector3(Main.position.x, Main.position.y, Main.position.z);
    }
}

,

LastUpdate() doesn’t exist in Unity, it’s LateUpdate(). Also, don’t track the Z axis so the camera keeps it’s distance from the player.

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

public class CameraScript : MonoBehaviour
{
    public Transform Main;
 private Camera camera;

 void Start()
 {
     camera = GetComponent<Camera>();
 }

 void LateUpdate()
 {
     camera.transform.position = new Vector3(Main.position.x, Main.position.y, camera.transform.position.z);
 }
}