Editing a variable within another script.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By N-jima

Hi, i’m currently making a simple RPG game in 3d. And I want to change the value of a variable I have defined in another script. I was following a tutorial and ended up with this code.

extends Area

onready var buff = get_node(“.”)

func _on_Area_area_entered(area):
buff.can_step = false

However this returns an error "Invalid set index ‘can_step’ (on base: ‘Area(Area.gd)’) with value of type ‘bool’.

Am very confused as to why i’m receiving this error as I see this code working perfectly fine on other examples and tutorials.

:bust_in_silhouette: Reply From: kidscancode

get_node(".") does nothing at all. It’s unlikely you’ve seen that in a tutorial.

You need to use the NodePath from the current node to the destination. See here for examples: