export(PackedScene) onready var hitbox
var temp_hitbox = hitbox.instance()
The variable hitbox is marked as onready, this is equal to creating the variable inside the _ready function. The variable temp_hitbox isn’t marked as onready, this means it’s intitialized before hitbox.
To fix the problem you need to set the variable temp_hitbox as onready like this:
export(PackedScene) onready var hitbox
onready var temp_hitbox = hitbox.instance()
Thank you. I spent a few hours on this. Must have overlooked that. Haha.