save funtion c#

hey guys, I am trying to code a save function for my game. where it saves what i pick up and where i am when i hit a certain checkpoint. So for instance, if there was a thin hallway with 2 apples on the ground, that i can pick up, one right in front of me, and one at the end of the hallway, i would want it to save when i pick up the second apple and the end of the hall. i don’t want it to save at the point where i pick up the object, i would like it to be when i walk through a collider of an empty game object or possibly a trigger of some sort. i don’t think i want it to keep the players position if they exit the game.

thanks for any help you can offer

best.

Create a script:

CheckPointManager : MonoBehaviour 
{
         public static Vector3 lastCheckPoint = new Vector3 (0,0,0);
         public static int numberOfApples;
         public static int numberOfBananas;         
}

Create script:

CheckPoint : MonoBehaviour 
{
   OnTriggerCollision (Collider other)
   {
     if (other.tag == "Player")
     {
       CheckPointManager.lastCheckPoint = this.transform.position;
     }
   }
}

Same logic with with the collectibles.
-Hope i helped