My code does not run gdt4.2.1

Godot Version



Every time I press play, it doesn’t execute and I get the error: Invalid call. Nonexistent function ‘instance’ in base ‘PackedScene’.

This is the code for my main scene that has a single 2d node
extends Node2D

Preload your scenes

var Escena1 = preload(“res://Intro.tscn”)
var Escena2 = preload(“res://Loadingmenu.tscn”)

This function will be called when the node enters the scene tree for the first time.

func _ready():
# Imprime la escena1 y escena2 después de pre-cargarlas

# Instance the first scene and add it to the current scene
var instancia_escena1 = Escena1.instance() = "Intro"

This function will be called when the first scene is done

func _on_Escena1_done():
# Remove the first scene

# Instance the second scene and add it to the current scene
var instancia_escena2 = Escena2.instance() = "Loadingmenu"

its instantiate() now I don’t know why they made that decision.

here is why

commit e28fd07b2bbe78db0f286604a6eb469d8a0664be
Author: Aaron Record
Date:   Thu Jun 17 16:03:09 2021 -0600

    Rename `instance()`->`instantiate()` when it's a verb

because of grammar


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.