Not sure WHAT the problem is

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

I do not understand what it is trying to tell me.

Error: Invalid call. Nonexistent function ‘instance’ in base ‘Nil’.
0 - res://Main.gd:13 - at function: _on_MobTimer_timeout

extends Node

export (PackedScene) var mob_scene


func _ready():
	randomize()

func _on_MobTimer_timeout():
	var mob_spawn_location = $MobPath/MobSpawnLocation
	mob_spawn_location.unit_offset = randf()

	var mob = mob_scene.instance()
	add_child(mob)

	mob.position = mob_spawn_location.position

	var direction = mob_spawn_location.rotation + PI / 2
	direction += rand_range(-PI / 4, PI / 4)
	mob.rotation = direction

	var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
	mob.linear_velocity = velocity.rotated(direction)
:bust_in_silhouette: Reply From: Asthmar

Error: Invalid call. Nonexistent function ‘instance’ in base ‘Nil’.
From my understanding Nil mean something is null, or doesn’t exist.

0 - res://Main.gd:13 - at function: onMobTimer_timeout
The error is under your Timeout function

So when you call the function instance() you made an invalid call. This means you cannot instance that scene. There may be a mistake with your file path. I’m not super familiar with packed scenes as I don’t ever use them. So instead I would suggest preloading the scene like this .

var scene = preload(“res://scene.tscn”).instance()

I hope that helps