Nonexistent funtion 'instance' in base 'GD script'

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

While trying to instance a scene via code i’m getting this error and i dont know why.

this is the problem code

 var fireball = preload("res://Fireball.gd")
 var fireball_n =fireball.instance()
 
 
func _on_Spieler_Manaager_cast(): 	
    add_child(fireball_n)

I formatted your code for you. Please use the proper formatting when posting code blocks, so the _ don’t get processed as italics.

kidscancode | 2019-08-10 19:23

:bust_in_silhouette: Reply From: kidscancode

instance() is a method of PackedScene: PackedScene — Godot Engine (latest) documentation in English

You’re loading a Script, not a PackedScene. Try preload("res://Fireball.tscn")

Thank you so much. I am truly an idiot for not noticing that.

Liv | 2019-08-10 19:32