How to change Boolean variable in a different script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HarryCourt
:warning: Old Version Published before Godot 3 was released.

So, I have two scripts, one has you tap a button, and upon tapping, will change a variable to “true”, which is in another script. However, it isn’t working as expected. The button is pressed and works correctly, but doesn’t change the variable to true.

Scene tree: Screenshot - c437b8d29f83640487cb8e571586fabc - Gyazo (The img HTML tag doesn’t want to work.)
enter image description here

Tapping Script:

extends RichTextLabel

# Things that actually make the game work
var counter = 0
var timer = 0
var pressed = false

# Power Up Varibles
onready var powerSign = false

func _ready():
	# Tell what to do when the "Play" button is pressed.
	set_fixed_process(true)
	set_process_input(true)
	self.set_text("Money: $0")
    

func _fixed_process(delta):
	# Tap, Gain, Repeat...
	var press = Input.is_action_pressed("Press")
	
	if press and not pressed:
		print("Tap")
		counter += 1
		self.clear()
		self.add_text(str("Money: $", counter)) 
	pressed = press
	
	
	# Enough tapping, lets get rich!
func _on_Timer_timeout():
	
	# Open Sign (Add +$1 a second)
	if (powerSign == true):
		counter += 1
		self.clear()
		self.add_text(str("Money: $", counter))
		print("Added money (powerSign)")
	
	

Buy Button Script:

extends Button

# Variables
onready var powerSign = get_tree().get_root().get_node("World/Counter").get("powerSign")

func _ready():
	set_fixed_process(true)

func _fixed_process(delta):
	pass


func _on_Button_pressed():
	
	if (powerSign == false):
		powerSign = true
		print("Button Pressed, it should work...")
:bust_in_silhouette: Reply From: volzhs

boolean is not reference.
the powerSign variables are actually different on World/Counter and Button
you need to get a reference of Counter

extends Button

# Variables
onready var counter = get_node("/root/World/Counter")

func _ready():
    pass

func _on_Button_pressed():
    if (counter.powerSign == false):
        counter.powerSign = true
        print("Button Pressed, it should work...")

Thanks for the quick reply!

HarryCourt | 2017-11-27 11:22