Help with code from video

So its only the parts of the code where I need to get arrays for the cards but it just gives me an “identifier level not found in current scope” but in the video the guy does it fine without any issues.

extends Area2D
class_name Card

func _ready():
	if level.is_card_collected():
		$animationplayer.play("Get")
	$CollisionShape2D.set_deffered("disabled", true)
		

func _on_body_entered(body):
	$animationplayer.play("Get")
	$CollisionShape2D.set_deffered("disabled", true)
	


func _on_animation_player_animation_finished(anim_name):
	if anim_name == "Get":
		level.get_card()
		$AnimationPlayer.play("Collected")


##The other code from video
extends Node

const levels = ["Galaxy map"]


var cards: Array = []

func _init():
	for l in len(levels):
		var level_cards = [false]
		cards.append(level_cards)

func get_card():
	cards[0][0] = true
	
func is_card_collected():
	return cards[0][0]

  


You’re trying to do something with “level” without defining what “level” is.

level.is_card_collected()

level.get_card()

Is level some kind of global that you have not added? Or did you miss something in the tutorial?

Rewatch the tutorial and see if you can find it.

The thing you’re missing is at 7:00 in the video: The level.gd script is supposed to be an autoload. You can add this at Project -> Project settings -> Globals -> Autoload

Big thanks. When I load the scene however what ends happening is I walk into the card and the animation doesn’t play. I’m gonna work on the rest of the level just wanted to try and see why this is happening.

You disable the collision shape as soon as this object is ready, maybe you meant to indent the $CollisionShape2D line as well?

I tried doing the indent and it gave me a “Error at (16, 1): Expected statement, found “Indent” instead.”

So I removed it then this happens

And gives me a “Invalid call. Nonexistent function ‘set_deffered’ in base ‘CollisionShape2D’.”

it’s deferred with two rs not two fs

Oh my god i feel so silly now it was literally just my atrocious spelling lol thanks a ton!