Retro, the problem is that you are trying to access a object before it even exists, Canvas2 will only exist after you instantiate it. And since you are instantiating it as GameObject you are able to change the variables and etc, otherwise you wouldn’t be able to do that, since it’s a prefab and it would be trying to clone the info that resides within the original prefab (points = 0). Since you are instantiating it as gameobject and giving a name to it (scoreText in this case), you should be using this name that you gave to access this instance of the prefab.
The text is inside a gameobject which is inside the Canvas Gameobject, so you have to access scoreText’s child, you could access it using the child name with scoreText.transform.Find(“Text”).gameObject, or using the index:
scoreText.transform.GetChild(0).gameObject.GetComponent<TextScript>().Points;
// scoreText = instance of the Canvas2 Prefab being instantiated by this event;
// .transform.GetChild(0).gameObject = accessing the Text GameObject inside this instance of the Canvas2;
// .GetComponent<TextScript>().Points = the integer inside the Text's script inside this instance of the Canvas2;
if you add this code between line 45 and line 46 it will probably work as you intended to, you should delete lines 39~43;