The identifier "Mob" isn't declared in the current scope.

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

Even though I have selected the Mob scene in the Script Variables under the Inspector tab, I keep getting the error mentioned in the title.

extends Node

export (PackedScene) var mob
var score

func _ready():

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass

func game_over():

func new_game():
	score = 0

func _on_MobTimer_timeout():
	$MobPath/MobSpawnLocation.offset = randi()
	var mob = Mob.instance() #This is the line that causes the error

func _on_ScoreTimer_timeout():
	score += 1

func _on_StartTimer_timeout():

Would appreciate any tips to help solve this issue.

:bust_in_silhouette: Reply From: rakkarage

you may have selected the Mob scene but you put it in the mob variable
so when you use it you need to use mob

var m = mob.instance()

Upon attempting the solution mentioned above no errors were produced on compilation, although it produced the following warning:

The local variable 'mob' is shadowing an already-defined variable at line 3.

And upon running the compiled game, the following error is produced:

Invalid call. Nonexistent function 'instance' in base 'PathFollow2D'.

which points to the line var m = mob.instance()

msherif | 2020-09-16 08:19

I have resolved the issue in the answer I provided.
It was just an issue of case sensitivity, which I hadn’t caught.
Thank you for your help.

msherif | 2020-09-16 08:34

:bust_in_silhouette: Reply From: msherif

I found the issue to be resolved when I changed this line:

export (PackedScene) var mob

To this line:

export (PackedScene) var Mob