for some reason it works when dialof is there but doesnt work if its not there, i want it to work once its visible

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

extends TextureRect

export var dialogPath = “”
export(float) var DialogSpeed = 0.05

var dialog
var phraseNum = 0
var phraseNumTotal = 14
var finished = false

func _ready():
$“…/TextTimer”.wait_time = DialogSpeed
dialog = getDialog()
assert(dialog, “Dialog not found”)
nextPhrase()
#Option
_on_Option1_visibility_changed()
_on_Option2_visibility_changed()

func _process(_delta):
$“…/Indicator”.visible = finished
if Input.is_action_just_pressed(“ui_accept”):
if finished:
nextPhrase()
else:
$Dialog.visible_characters = len($Dialog.text)
#Option
_on_Option1_visibility_changed()
_on_Option2_visibility_changed()

func getDialog() → Array:
var f = File.new()
assert(f.file_exists(dialogPath), “File path does not exist”)

f.open(dialogPath, File.READ)
var json = f.get_as_text()

var output = parse_json(json)

if typeof(output) == TYPE_ARRAY:
	return output
else:
	return []

func nextPhrase() → void:
if phraseNum >= len(dialog):
queue_free()
return

finished = false

$Name.bbcode_text = dialog[phraseNum]["Name"]
$Dialog.bbcode_text = dialog[phraseNum]["Dialog"]

$Dialog.visible_characters = 0

var f = File.new()
var image = dialog[phraseNum]["Name"] + dialog[phraseNum]["State"] + ".png"
if f.file_exists(image):
	$"../Character".texture = load(image)
else:
	$"../Character".texture = null

while $Dialog.visible_characters < len($Dialog.text):
		$Dialog.visible_characters += 1
		$"../TextTimer".start()
		yield($"../TextTimer", "timeout")

finished = true
phraseNum += 1
print(phraseNum)
return

#Node

func _on_Option1_visibility_changed():
if phraseNum >= phraseNumTotal:
$“…/ButtonSorter/Option1”.visible = 1
else:
$“…/ButtonSorter/Option1”.visible = 0

func _on_Option2_visibility_changed():
if phraseNum >= phraseNumTotal:
$“…/ButtonSorter/Option2”.visible = 1
else:
$“…/ButtonSorter/Option2”.visible = 0

func _on_Option1_pressed():
get_tree().change_scene(“res://StartScene/StartScene.tscn”)

func _on_Option2_pressed():
get_tree().change_scene(“res://StartScene/StartScene.tscn”)

The large node should be # node
and for short the button was working fine with the dialogue, once it was over the dialog ended or null and for some reason the buttons don’t work, and I want then to work please help.

ExpNeeded | 2023-05-12 16:43

:bust_in_silhouette: Reply From: ExpNeeded

To me in the future, add the func to ready and progress