So I have this dialogue box made and its script is this:
extends Control
var dialog = [
"Hello World",
"You are stupid",
"Boo"
]
var dialog_index = 0
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
visible = true
load_dialog()
func load_dialog():
if dialog_index < dialog.size():
$RichTextLabel.bbcode_text = dialog[dialog_index]
$RichTextLabel.percent_visible = 0
$Tween.interpolate_property(
$RichTextLabel, "percent_visible", 0, 4, 1,
Tween.TRANS_LINEAR, Tween.EASE_OUT_IN
)
$Tween.start()
else:
queue_free()
visible = false
dialog_index += 1
and the dialogue box is working fine, but then i have this StaticBody2D object that has this script attached
extends StaticBody2D
func interact():
load("res://scripts/DialogBox.gd")
now what happening is that I have a character who has a raycast, and if raycast is colliding with the StaticBody and Z is pressed, this function gets called, when i press it once everything works but I cant make it work the second time and im really frustrated xD
how do i fix this? ;-;