Help on making the textbox dissapear with the 'confirm' input

Godot Version

godot 4.7.stable

Question

i’ve been knocking at this for quite some time now and i cant find a solution. plez help

here’s the code:

func _on_interact():
	dialoguebox.visible = true
	print ("you're reading the sign")
	#...
	dialoguebox.visible = false

as previously said i want to make the ‘dialoguebox.visible’ false after inputing confirm (witch is already being used to open the ‘dialoguebox’ in the first place)

i’ve tried to use ‘await Input.is_action_just_pressed (“confirm”)’ but that didn’t await for anything. I even tested the print(Input.is…just_pressed (“confirm”)) and it worked fine

next i tried to se if the game was registering me opening the box and closing it in the same frame because the button was pressed on that frame and after putting a dalay of a second before the await it didn’t fix anything

please help I’ve been stuck at this for the whole day and i couldn’t find the solution anywhere.
Thanks for reading!

Would this work if you used a condition, such as..? …

if dialoguebox.visible == true:
    print ("you're reading the sign")
    dialoguebox.visible = false

functions run from top to bottom, await can interrupt them but it’s best to avoid await as much as possible. You could use _unhandled_input to hide the sign when such an input is pressed

func _on_interact():
	dialoguebox.visible = true
	print ("you're reading the sign")
	#...

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed("confirm"):
		dialoguebox.visible = false

Hey, thanks for the comment

but i want the dialoguebox to only dissapear after pressing confirm

sorry for the missunderstanding

so i have tried that but the ‘dialoguebox’ still went invisible instantly as i read it.
at least i think so, the “you’re reading the sign” message showed up so the code did tun correctly

i don’t know if this would help or just make this more confusing but there’s a whole lot of code that happens to run that ‘_on_interact()’ function that may help figure out what isn’t working here.

should i send it? its a pretty long sequence. I followed a random youtube video on making an interactable

Thanks for the help!

What triggers _on_interact()?

There is this code on another script

func _input(_event: InputEvent) -> void:
	if Input.is_action_just_pressed("confirm") and can_interact:
		if current_interactions:
			can_interact = false
			await current_interactions[0].interact.call()
			can_interact = true

current_interactions is a variable with all of the area2ds that enter this other area2d, one of these areas is where that code is located

and this is the .interact i think

@export var interact_name: String = ""
@export var is_interactable: bool = true

var interact: Callable = func():
	pass

i don’t really know what it does it’s also in another script that is integrated into the original script

i just realized that this is kind off a stupid way to explain so let me reiterate:

the original code talked about is in a script named sign.gd

the second code i mentioned is from a script called player.gd and it calls the other code after pressing confirm

the third code is some inheritance bs i dont fully understand and its the entire script named interactable.gd

Tysm for helping

So it’s been a week and summer break is almost over

I think I should just rewrite everything since the code is such spaghetti

Do you guys agree?