Cannot open file

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

E 0:00:00.660 load_interactive: Cannot open file ‘res://scenes/tile.tscn’.
<C++ Error> Condition “err != OK” is true. Returned: Ref()
<C++ Source> scene/resources/resource_format_text.cpp:1232 @ load_interactive()
Main @ _init()
E 0:00:00.663 _load: Failed loading resource: res://scenes/tile.tscn. Make sure resources have been imported by opening the project in the editor at least once.
<C++ Error> Condition “found” is true. Returned: RES()
<C++ Source> core/io/resource_loader.cpp:282 @ _load()
Main @ _init()

Somehow it run once after loading files into inspector but now also throws this error in debugger stack frames gd 4 at function:_init
extends Node2D

var scene = load(“res://scenes/tile.tscn”)
var scene_instance = scene.instance()
func scenadd():

Declare member variables here. Examples:

var a = 2

var b = “text”

Called when the node enters the scene tree for the first time.

func _ready():
pass # Replace with function body.

Called every frame. ‘delta’ is the elapsed time since the previous frame.

#func _process(delta):


Please post the full debugger message, you haven’t given us really anything to go off of to help you.

timothybrentwood | 2021-11-02 13:40

:bust_in_silhouette: Reply From: DaddyMonster

You need to give Godot a chance to fire up with:

Change var scene = load("res://scenes/tile.tscn") to var scene = preload("res://scenes/tile.tscn")

Move the rest of the code within your _ready method. As the default comments say, that fires when your node is good to go. In Godot, you can only declare member variables outside methods, everything else should go in a function. Like this:

extends Node2D

var scene = preload("res://scenes/tile.tscn")

func _ready():
    var scene_instance = scene.instance()

ps. You see the little curly braces above when you type? Just highlight the code and click that, it’ll be a million times more readable.

Godot Forum doesn’t have the insert code so I didn’t expect it here

cloa513 | 2021-11-02 23:46

Oh, don’t worry in the slightest. I only mentioned the formatting because it made the problem easy to miss and so you’ll know next time. Good luck with your game!

DaddyMonster | 2021-11-03 19:00