Instantiate canvas on mouse position?[Solved-ish]

Hi there, I’ve been trying to instantiate a text on my mouse position for my clicker game, although it works just fine by instantiating a gameObject, whenever i instantiate a canvas with a text the text is always anchored to the middle of the screen, no matter the position i instantiate it on

    void OnMouseDown()
    {
        corgiAmount += addAmount;
        Instance();

    }

    void Instance()
    {
        pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        pos.z = 10;
        Instantiate(textCanvas, pos, Quaternion.identity);
        a.text = "+" + addAmount.ToString("F0") + " corgis";
    }

Help would be greatly appreciated!

EDIT: Didn’t get it working but skip the canvas and it works pretty fine

I’m assuming you already have a canvas and you are not instantiating a canvas but a UI.Text element.
If so, the problem might be that your text element is not instantiated as a child of the canvas.

Try this:

void Instance()
    {
        pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        pos.z = 10;
        GameObject go;
        go = Instantiate(textCanvas, pos, Quaternion.identity) as GameObject;
        go.transform.parent = canvas.transform.parent;
        go.transform.position = pos;
        a.text = "+" + addAmount.ToString("F0") + " corgis";
    }