This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello! I'm trying to make a button that makes a Spatial node and it's children invisible.

    onready var LL = $lightscar

func _process(delta):
    if Input.is_action_just_pressed("engine"):
        engineEnabled = !engineEnabled
        print(engineEnabled)
        if not engineEnabled:
            LL.visible = false

I keep getting Invalid set index 'visible' (on base: 'null instance') with value of type 'bool'. when I try to use it! How can I fix?

Godot version 3.3.2
in Engine by (16 points)

Hi.
The error means that LL is null and not an object. Therefore the problem arises from:

onready var LL = $lightscar

are you sure that $lightscar is correct?

2 Answers

0 votes
if get_node_or_null(NodePath("lightscar")):
    $lightscar.visible = false

this checks whether the node exists but i cant see what the problem is

by (467 points)
+1 vote

Hello mate, I just had the same problem. The variable becomes null for some reason, so i recreated the variable for ex:

onready var LL = $lightscar

func _process():
var ll = $lightscar

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.