ERROR: Parameter "p_child" is null

I encountered an ERROR, ERROR: Parameter “p_child” is null. It will crash my Windows application. Now, I canvassed the locations where the questions were asked. This error occurs when I load(“xxxxx.tscn”) and add a reference to the node in the global script. Well, I don’t know the exact cause of the problem.

How did you encounter this error? :thinking:

I defined a method in the global script.

func get_scene_instance(scene) -> Node:
    var path = global_scene_tree.get(scene)
    return load(path).instantiate()

When I add_child the reference and then try to package the exe, the console gets this error

What is meant by p_child?
It is better to leave the script complete

This is the complete error message that the console gave me.

func get_scene_instance(scene) -> Node:
    var path = global_scene_tree.get(scene)
    return load(path).instantiate()

Is that all the script you wrote?

Yes, when I tried to add_child the returned node in a non-global script, he reported an error. However, I fixed the problem, and before I added _child, all the required children were loaded and not null