trying to make a function, but don't know where to put it in the script.

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

public class statroll : MonoBehaviour {

    public void RandomizeStats() {

    for(int x = 0; x < 20; x++)
    {
        int str = 0, agi = 0, inte = 0;
        int statroll = Random.Range(1,3);
        switch (statroll)
        {
        case 3:
            str++;
            break;
        case 2:
            agi++;
            break;
        case 1:
            inte++;
            break;
        default:
            Debug.LogError("Something went wrong, probbably with my Random.Range bounds!");
            x--;
            break;
        }
            Debug.Log("str=" + str + " :agi=" + agi + " :inte=" + inte);

    }

}
}

I’m trying to make a Onclick function, but every time I try to put a public text or a public button it says it’s incorrect. I already put a public void, but I’m even sure if that’s in the right place either.

using UnityEngine.UI;

The docs really can help - https://docs.unity3d.com/ScriptReference/UI.Text.html

Here is the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class statroll : MonoBehaviour {
    public void RandomizeStats() {
    for(int x = 0; x < 20; x++)
    {
        int str = 0, agi = 0, inte = 0;
        int statroll = Random.Range(1,3);
        switch (statroll)
        {
        case 3:
            str++;
            break;
        case 2:
            agi++;
            break;
        case 1:
            inte++;
            break;
        default:
            Debug.LogError("Something went wrong, probbably with my Random.Range bounds!");
            x--;
            break;
        }
            Debug.Log("str=" + str + " :agi=" + agi + " :inte=" + inte);
    }
}

    public void myOnclick()
    {
        Debug.Log("the button was clicked");
    }
}

in unity you need to add the onclick listener. then point that to the gameobject that has this script running on it. from the drop down select this script and function myOnclick.