metr1x
I had some trouble getting custom scripts attached to my root scene. Maybe this will be of help - this is how I do it:
var script_manager_scene = load("res://scenes/rootScene/ScriptManager.tscn")
script_manager = script_manager_scene.instance()
add_child(script_manager)
var new_script = GDScript.new()
new_script.source_code = custom_script_text # this is your custom script
new_script.reload()
script_manager.set_script(new_script)
script_manager.set_process(true)
Note the line 'new_script.reload()'. I think I found in my initial attempts if I had this in the wrong place and it broke the setup.
Also I set this up on the first process tick of my scene. It probably works just fine in _ready but I needed to do this for other reasons.
For debugging make sure you've got the script working when hard coded (placed normally in Godot) before attempting the dynamic load.