Invalid set index 'texture' (on base: 'null instance') with value of type 'StreamTexture'

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rayu
var textures = [
			'res://Emojis/Emoji_set1/EyeClosed_Smiley_120x120.png',
			'res://Emojis/Emoji_set2/Frog_130x130.png',
			'res://Emojis/Emoji_set3/Cool_Emoji120x120.png',
]	

func _ready() -> void:
	Globals.load_store()
	$Sprite.texture = load(textures[Globals.store.selected])  <---- Error

Invalid set index ‘texture’ (on base: ‘null instance’) with value of type ‘StreamTexture’

i found this, but didn’t solve my problem
https://forum.godotengine.org/65367/invalid-index-texture-base-null-instance-value-streamtexture

i had a similar problem here, did you had solve this problem? if so, pls let me know :smiley:

AXB | 2022-12-29 11:32

:bust_in_silhouette: Reply From: jgodfrey

Your $Sprite node reference is null. You need find out why that is…

this Scene has 1 node and it is a Sprite and it is called Sprite how can it be null ??

Rayu | 2020-11-19 21:27

Just a single Sprite node? So, the Sprite is the single, top-level node (and no other nodes)?

If so, is the above script attached to that Sprite node? If so, you just want this:

texture = load(textures[Globals.store.selected])

That $Sprite is attempting to access a child node, which doesn’t exist…

jgodfrey | 2020-11-19 22:29