How to add a custom node through GDScript? Usual approach not working...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Footurist

So, the question was already posed and answered, but this approach won’t work for me:

extends Node2D

var FancyTSButton = preload("res://addons/FancyTSButton/FancyTSButton.gd")

func _ready():
    var button = FancyTSButton.new()

After running it, nothing at all happens. The only error it reports is !is_inside_tree() is true while pointing to line 3. Any ideas?

:bust_in_silhouette: Reply From: Footurist

Never mind. Didn’t add as child.