Attempt to call function 'instantiate' in base 'null instance' on a null instance. me sale ese error ayudaaaa

extends Area2D

onready var Animal_Scene = load(“ress://Ecenas/Baca.tscn”)
var bool_spawn = true

var random = RandomNumberGenerator.new()

func _ready() → void:
random.randomize()

func _process(delta: float) → void:
spawn()

func spawn():
if bool_spawn:
$Timer.start()
bool_spawn = false
var animal_instance = Animal_Scene.instantiate()
animal_instance.position = Vector2(random.randi_range(10, 1188),random.randi_range(10, 687))
add_child(animal_instance)

func _on_Timer_timeout():
bool_spawn = true

Perhaps it should be:
load(“res://Ecenas/Baca.tscn”)

2 Likes

Talvez voy a probar

haora sale esto Invalid call. Nonexistent function ‘instantiate’ in base ‘PackedScene’.

It’s “instantiate” in Godot 4. In 3 it’s “instance”.

grasias