I need help with my jeopardy game in Godot for my assignment

Godot Version

v.4.2.2

Question

script one

extends Node2D

var button_choice = 0
func get_variable():
	return button_choice
func _on__1100_pressed():
	get_tree().change_scene_to_file("res://question.tscn")
	button_choice = 11

script 2
extends Label
func _ready():
	get_node("/root/Gameboard").get_variable(button_choice)
	if button_choice == 11:
		text = "yes"
	elif button_choice == 12:
		text = "no"

i am trying to make a jeopardy game and it wont let me call the variable from script one in to the second script

change_scene_to_file will remove the current scene node (which is Gameboard I guess) from the tree. So the variable is not present anymore.

Instead of

get_tree().change_scene_to_file(“res://question.tscn”)

do something like

get_tree().root.add_child(preload(“res://question.tscn”).instantiate())

This way Gameboard is still available when you call the variable.