• Godot Help
  • why am I get a error when load and set my sprite texture?

"Invalid set index ´texture´(on base: ´null instance´) with value of type ´CompressedTexture2D"
The error message pops when I attempt to run the game.
The code I use is a copy-paste from a previous node. The node form where the code is originally from still runs perfectly, yet this new node does not. It is the same node type (margain container.).

*'const** Cardname = "Godette"
#_____________________________________________________________________________

**@onready var UnitArt**=$"Unit Art" #Sprite note
**var** UnitImg = str("res://Assets/Units/Unit_Art/",Cardname,".png")


**func _setting_textures_and_texts():**
	UnitArt.texture=load(UnitImg)

I have tried to change the image file type and re-import it in differetn formats but to no avail. Anyone has any idea why and how to fix it? I am also curious as to why it would work in one node and suddenly not in another?

Is there maybe an error on the script attached to the unit art node which would cause it to not run properly and the texture to be null?