Nonexistent function '...' in base '...'

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

can anyone pls help
i stiil get this message:
Nonexistent function instance in base ‘GDscript’

this is the script

extends Panel

var item = null
var ItemClass = preload(“res://Item.gd”)

func _ready():
if randi() % 2 == 0:
add_child(item)
item = ItemClass.instance()

:bust_in_silhouette: Reply From: yrtv
var ItemClass = preload("res://Item.gd")

itemClass now has type GDScript.

ItemClass.instance()

GDScript does not have instance() method.

Without additional context answer end here. What are you trying to do?

i was trying to follow this tutorial

https://www.youtube.com/watch?v=FHYb63ppHmk&t=331s
its on 5:32

and i still get this error

Castor1010 | 2021-02-08 05:23

:bust_in_silhouette: Reply From: Scavex
var ItemClass = preload("res://Item.gd")

Take a good look. Here you need to preload a scene not a script ! Even in the tutorial it’s

var ItemClass = preload("res://Item.tscn")