get tags and keep them in a string,keep tag in a datatype?

so i want to add a string keeping the tag, but i am not sure how to get the tag and keep it into a string.

using UnityEngine;
using UnityEngine.SceneManagement;

public class leveltel : MonoBehaviour
{

public string DebugLog;
public string FinishObjName;
public Sprite SpriteCompleted;

public string SceneName;
int Level;

public bool Completed;

void Start()
{

    GameObject.FindWithTag("Player") //i am trying to search it, but i don't know how to get it into a string.

    name = Player.tag;  //HERE
    /*
    so i want to get Player tag and put it into a string. 

        */
    GameObject.Find("SAVELOADSYSTEM").GetComponent<LoadManager>().level = Level;
    GameObject.Find(FinishObjName).GetComponent<Finish>().completed = Completed;
}
void Update()
{
    var distance = 3;
    if (Vector3.Distance(transform.position, Player.transform.position) < distance && Input.GetKeyDown(KeyCode.E))
    {
        Debug.Log(DebugLog);
        SceneManager.LoadScene("LVLSEL");
    }

    if (Completed == true)
    {
        this.GetComponent<SpriteRenderer>().sprite = SpriteCompleted;
    }

}

}
`,i want to get tag of “Player” and keep it into a String to use to detect if player completed level.

`using UnityEngine;
using UnityEngine.SceneManagement;

public class leveltel : MonoBehaviour
{

public string DebugLog;
public string FinishObjName;
public Sprite SpriteCompleted;

public string SceneName;
int Level;

public bool Completed;

void Start()
{

    GameObject.FindWithTag("Player").

    name = Player.tag;  //HERE
    /*
    so i want to get Player tag and put it into a string. 

        */
    GameObject.Find("SAVELOADSYSTEM").GetComponent<LoadManager>().level = Level;
    GameObject.Find(FinishObjName).GetComponent<Finish>().completed = Completed;
}
void Update()
{
    var distance = 3;
    if (Vector3.Distance(transform.position, Player.transform.position) < distance && Input.GetKeyDown(KeyCode.E))
    {
        Debug.Log(DebugLog);
        SceneManager.LoadScene("LVLSEL");
    }

    if (Completed == true)
    {
        this.GetComponent<SpriteRenderer>().sprite = SpriteCompleted;
    }

}

}

First of all, you will want to add the line the finds the object to a GameObject variable, like this:

public GameObject player;

void Start()
{
          player = GameObject.FindObjectWithTag("Player");

}

Then, assuming you already have a string variable, do this:

//put your string in place of player tag
Playertag = player.tag;

Hope this helps.

I know this is not related to the question but there is a more elegant way of finding the player in the scene. FindWithTag and other “Find” methods are sometimes inefficient. You can easily build singleton pattern here assuming you have only a player in the scene.

public class Player : MonoBehaviour
{
    public static Player Instance;
    void Awake()
    {
        if (Instance == null)
            Instance = this;
    }
}

and then you can easily access player components using Player.Instance.GetComponent<>…etc()
PS : Make sure you call Player.Instance from Start() otherwise you will get null reference
@costin88boss