Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SirSqueakers |
Node (parent) (where script is located) <------------ Scene
Sprite (child) (being affected by the script)
Code:
extends Node
func _ready():
$Sprite.visible = false
Error:
Invalid set index ‘visible’ (on base: ‘null instance’) with value of type ‘bool’.
PS: Im new to Godot…
Thanks In Advance
Scenetree:
Node (called scene)
Sprite (called Sprite)
Code:
extends node
func _ready():
$Sprite.visible = false
whenever i run it the error (shown above) occurs
visible is a property belonging to the Sprite
SirSqueakers | 2020-06-11 11:16
also in the error tab it shows this:
get_node: Node not found: Sprite
… Im utterly confused
SirSqueakers | 2020-06-11 11:19
extends node
func _ready():
$Sprite.visible = false
idk how to make a screenshot so this is it, literally, there’s nothing else, just this code
scene (on the right of it is script
)
Sprite (on the right of it is toggle visibility
)
Sprite already exists there is no code instancing it, or anything, its all manual except the code above, telling the Sprite what to do when func ready
is called the script gets the node Sprite, then it changes its visibility to false, i think its something “with scene” node
cus, when i put the script in the “Sprite” node
and do self.visible = false, it works and i cannot see it, is my project cursed or is my path being read wrong, because it also shows that i cannot find node
“Sprite” even though its there!!! wth godot!?
SirSqueakers | 2020-06-12 11:20