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 (12 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?

1 Answer

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 (262 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 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 webmaster@godotengine.org with your username.