Simple Checkpoint system

Hi im very new to C# and im trying to make a simple checkpoint system with variable positions, every time the player collides with the latest checkpoint, that will be the latest checkpoint, i got this so far:

//starting position

public float xPos = -2.005395f;
public float yPos = 0.4081692f;
public float zPos = -1.894107f;

void OnTriggerEnter (Collider playerCollision)
{

//when the player touches the 'deathcube' the player dies (works fine)

    if (playerCollision.tag == "DeathCube")
    {
        gameObject.transform.position = new Vector3(xPos, yPos, zPos);
    }

//when the player touches the latest checkpoint, make this spot the new x, y, z coordinates, need help here

    else if (playerCollision.tag == "Checkpoint")
    {
        //how do i make this checkpoint into the new xPos, yPos, zPos variables
    }

//also if u can help here, this happens when i on top of a door and i press 'up' but it doesnt work very well, only on extremely precise spots, (its a square, with a square collider).

    else if (playerCollision.tag == "Finish") && (Input.GetKeyDown("o")))
    {
        gameObject.transform.position = new Vector3(27.79584f, 9.437206f, zPos);
    }
}

You really should store xPos yPos zPos as a vector, it's just a lot nicer.

public Vector3 Pos = new Vector3(-2.005395f, 0.4081692f, -1.894107f);

Then deathcube would become

gameObject.transform.position = Pos;

The checkpoint update would be

Pos = playerCollision.transform.position;

Or if you insist on doing it without a vector

xPos = playerCollision.transform.position.x;
yPos = playerCollision.transform.position.y;
zPos = playerCollision.transform.position.z;

Not really sure what you're trying to do for the last part, or what isn't working.

Though I think the problem might be that you're using onTriggerEnter but the behaviour you want should go in onTriggerStay, which is called nearly every frame that you are touching a trigger (compared to just the first time.)