Help needed with scripting TMPro

Hi everyone. Apologies in advance, I assume this may be a simple thing and while I have searched forums/watched tutorials/read manuals I’m just simply cannot make sense of this.

Within the game exists a button which will increase the age of the player as defined in the ‘Player’ script. I want a text log which will show a history of the player’s age as the aging button is pressed. I have created a simple version of what I want the canvas to look like but I am struggling to wrap my head around just how I should do this.

I originally assumed that I could just set the text within the Eventmanager script which is attached to the Content object. however this throws multiple errors. Also, I’ve realised that even if I get this working the age string will just update to the new one instead of creating a new line and showing the new age.

Again I’m sorry that this is so simple but I am really strugging. If someone could advise what I’m doing wrong or point me in a better direction I’d be very grateful. Thanks in advance!

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

public class Eventmanager : MonoBehaviour
{
    public static int char_age = 0;
    TextMeshPro count;

    // Start is called before the first frame update
    void Start()
    {
        count = GetComponent<TextMeshPro>();
    }

    // Update is called once per frame
    void Update()
    {
        char_age = Character.Age;
        count.text = "Age: " + char_age;
    }
}


using System;
using System.Threading;
using UnityEngine;

using Minnow.CharacterStats;


public class Character : MonoBehaviour
{
    public static int Age;

    System.Random r_rand = new System.Random();

    void Start ()
    {
        Age = 0;
    }

    void Update()
    {
        Age = AgeScript.PlayerAge;
    }
}


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

public class AgeScript : MonoBehaviour

{
    public static int PlayerAge;

    public void AgePlayer()

    {
        PlayerAge++;
    }
}

If I understand you correctly you want to change the text of a textmeshpro text through a script. If so, then you should use the component TextMeshProUGUI instead of TextMeshPro. So like this:

 public class Eventmanager : MonoBehaviour
 {
     public static int char_age = 0;
     TextMeshProUGUI count;
 
     // Start is called before the first frame update
     void Start()
     {
         count = GetComponent<TextMeshProUGUI>();
     }
 
     // Update is called once per frame
     void Update()
     {
         char_age = Character.Age;
         count.text = "Age: " + char_age;
     }
 }

Hope this helps.