Invalid assignment of property or key 'texture' with value of type 'CompressedTexture2D' on a base object of type 'Nil'

Godot 4.3

i’m having trouble with a space invaders clone i’m trying to build.

extends Area2D

@export var sprite: Sprite2D
@export var texture_array: Array[Texture2D]
var damage = 0
var max_damage = 3

func _on_area_entered(area: Area2D) -> void:
	if area is Laser || area is InvaderShot:
		area.queue_free()
		if damage < max_damage:
			damage += 1
			>>> sprite.texture = texture_array[damage - 1]<<<
		else:
			queue_free()
	
	if area is Invader:
		queue_free()

i’ve highlited the line that keeps giving me this error

Is your sprite variable assigned? Make sure to check the inspector for exported variables.

yeah, i overlooked that :p.
thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.