queue_free() doesn’t exist on enemy_list because it is an Array of enemies, further more queue_free() does not work as a condition, it merely deletes the node.
You need to go through each element in your list (a for loop), connect to a signal when the each enemy is removed from the game (.tree_exiting.connect()) and count up a new variable until it reaches the same number as the array has items.
extends Node2D
var enemy_list: Array[Node2D] = [$"chicken", $"chicken3", $"chicken8", $gateopener, $"chicken2", $"chicken4", $"chicken5", $"chicken6"]
var enemies_died: int = 0
func _ready() -> void:
# connect to each enemy's death
for enemy in enemy_list:
enemy.tree_exiting.connect(_on_enemy_perish)
func _on_enemy_perish() -> void:
enemies_died += 1
if enemies_died >= enemy_list.size():
get_tree().change_scene_to_file("res://scenes/game screens/barn.tscn")
It would seem one of them is not, or is deleted upon _ready, next time you get that error check your stack trace for local variables, you could see enemy is null and maybe you can look through the enemy_list for null values. You could also print(enemy_list) to look for null values, which based on this post sounds like all of them are null, probably not children of this node.