0 votes

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:
item = ItemClass.instance()

in Engine by (35 points)

2 Answers

+2 votes
Best answer
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") 
by (416 points)
selected by
0 votes
var ItemClass = preload("res://Item.gd")

itemClass now has type GDScript.


GDScript does not have instance() method.

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

by (890 points)

i was trying to follow this tutorial

its on 5:32

and i still get this error

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.