Teleporting

Hi, I want to teleport the player in to a certain location in certain conditions.
The variable “value” is the checkpoint. When collided with an object I need to teleport to a checkpoint depending on the “value”. The script is currently teleporting me to the 5th checkpoint.

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

public class AI : MonoBehaviour
{
    [Header("Text and Setup")]
    public TextMeshProUGUI dialougeText; // The AI Dialouge Box Text
    public GameObject player; // The player

    [Header("Trigger Settings")] // Triggers
    public GameObject fallBorder;
    public GameObject trigger0;
    public GameObject trigger1;
    public GameObject trigger2;
    public GameObject trigger3;
    public GameObject trigger4;
    public GameObject trigger5;

    [Header("Dialouge Settings")] // Text Settings
    public string text0;
    public string text1;
    public string text2;
    public string text3;
    public string text4;
    public string text5;

    [Header("Script Debugging")]
    public int value;

    void Start()
    {
        dialougeText = dialougeText.GetComponent<TextMeshProUGUI>(); // Get The Component
    }
    public void OnTriggerEnter(Collider other) // On Trigger Collision
    {
        if (other.gameObject.name == fallBorder.name) // If the tag is ...
        {
            Debug.Log("Player falled!"); // Trigger Confirm
            Teleport(); // Teleport
        }

        if (other.gameObject.name == trigger0.name) // If the name is ...
        {
            Debug.Log("Trigger0 enter"); // Trigger Confirm
            dialougeText.text = (text0); // Set Text
            value = 0;
        }

        if (other.gameObject.name == trigger1.name) // If the name is ...
        {
            Debug.Log("Trigger1 enter"); // Trigger Confirm
            dialougeText.text = (text1); // Set Text
            value = 1;
        }

        if (other.gameObject.name == trigger2.name) // If the name is ...
        {
            Debug.Log("Trigger2 enter"); // Trigger Confirm
            dialougeText.text = (text2); // Set Text
            value = 2;
        }

        if (other.gameObject.name == trigger3.name) // If the name is ...
        {
            Debug.Log("Trigger3 enter"); // Trigger Confirm
            dialougeText.text = (text3); // Set Text
            value = 3;
        }

        if (other.gameObject.name == trigger4.name) // If the name is ...
        {
            Debug.Log("Trigger4 enter"); // Trigger Confirm
            dialougeText.text = (text4); // Set Text
            value = 4;
        }

        if (other.gameObject.name == trigger5.name) // If the name is ...
        {
            Debug.Log("Trigger5 enter"); // Trigger Confirm
            dialougeText.text = (text5); // Set Text
            value = 5;
        }
    }

    public void Teleport()
    {
        player.transform.position = trigger5.transform.position;
    }
}

First I want to mention that it is a liitle tricky using an int. It is better to make your “value” variable Transform or Game object. But if you still want to leave it as int chnage your teleport funciton to this:

   public void Teleport()
        {
            switch (value)
            {
                default:
                    break;
                case 0:
                    gameObject.transform.position = trigger0.transfrom.position;
                    break;
                case 1:
                    gameObject.transform.position = trigger1.transfrom.position;
                    break;
                case 2:
                    gameObject.transform.position = trigger2.transfrom.position;
                    break;
                case 3:
                    gameObject.transform.position = trigger3.transfrom.position;
                    break;
                case 4:
                    gameObject.transform.position = trigger4.transfrom.position;
                    break;
                case 5:
                    gameObject.transform.position = trigger5.transfrom.position;
                    break;
            }
        }

However this cannot consists fallBorder. You need to do it with if statement.