I need to access the public string variable on the script that is attached on my UI button and also to concatenate it.

Just to be clear this is for a word game, I have 26 buttons that contains letters from A - Z and each button has its own string value for the letter (example: Button A has a string value of “a”). Then i want to concatenate the string values whenever the player is trying to create a word.

using UnityEngine;
using UnityEngine.UI;


public class LetterTiles : MonoBehaviour {

    public string letter;
    public Text displayer;
    float addTime;
    string word;

    public GameObject tile;
    GameObject Tile;
    Vector3 scale = new Vector3(0.8f, 0.8f, 0);

    public void letterClick()
    {

        //wordBuild.currentWord += GetComponent(Type.GetType(letter));
        wordBuild.currentWord += GetComponent(letter);
        //wordBuild.currentWord += GetComponent<Button>;
        
        Debug.Log(wordBuild.currentWord);

    }

}

I’m not too sure what you are trying to do, but it looks like you are trying to add the letter string to the wordBuild.currentWord string. I believe the correct way to do this is with wordBuild.currentWord += letter;