Help with using resourceloader

I have an enemy spawner and am trying to use the resourceloader.

In _ready() i do :

ResourceLoader.load_threaded_request(enemy)

and down in the function that i use to spawn it, i do:

var enemy_scene = ResourceLoader.load_threaded_get(enemy)
var new_enemy = enemy_scene.instantiate()

and a little down the road i add it to the scene.

it works two times and then gives me this error:
image

telling me that the error lies in this line from above:
var new_enemy = enemy_scene.instantiate()

how can i make it stop giving this error?
All help is appriciated.

I believe i figured it out.

there are 4 parameters that must be passed in load_threaded_request:

  1. path, i filled that with the path to my enemy’s scene
  2. type_hint, i filled it with “” since that’s it’s default value
  3. use_sub_threads, i have it currently set to true since the docs says it makes the resource load faster, but might not keep it as i dont see a boost in performance
  4. cache_mode, i have this set to 1, since that makes it to where the resource loaded is reusable.

Then, instead of using load_threaded_get(), i did :

ResourceLoader.load()

load has 3 parameters that must be passed:

  1. path, i set that to the same path as what i have load_threaded_request
  2. type_hint, again i just set it to “” since it’s default is blank
  3. cache_mode, i set it to 1 as well to show that the resource im loading is meant to be reused.

i have the doccumentation here if you’re interested: