Disable F key not working in places needed

Godot Version

4.3

Question

I have set up dialogues in my game, I have 2 dialogues right now, welcome and tutorial, the flow goes like this: press F => welcome show => press F again => tutorial show.
now when reaching tutorial I don’t want the player to press F, so he won’t skip tutorial until completed, I set up 2 bools, one for welcome_completed, and the other is the can_trigger_dialogue for F key. I have tried many attempts to get it working, but haven’t succeeded, if anyone has any suggestions, please share.

dialogue script (located in the level scene)

func _unhandled_input(event: InputEvent) -> void:
	# Check if F key is pressed and we are allowed to trigger dialogues
	if event.is_action_pressed("dialogue") and Globals.can_trigger_dialogue:
		print("Dialogue action triggered!")

		# Handle Welcome Dialogue
		if not Globals.welcome_completed:
			# Show the welcome dialogue
			DialogueManager.show_dialogue_balloon(load("res://dialogues/welcome.dialogue"), "start")
			Globals.set_welcome_state(true)  # Update global flag
			Globals.set_can_trigger_dialogue(false)
			return

global script (not located in scene at all)

var can_trigger_dialogue: bool = true # for triggering dialogue by pressing F
var welcome_completed: bool = false
var track_tutorial_inputs: bool = false
var dialogue_active: bool = false
var tutorial_completed: bool = false
var discover_shown: bool = false


func set_can_trigger_dialogue(state: bool) -> void: # refer to F key
	can_trigger_dialogue = state
	print("Dialogue trigger state set to: ", can_trigger_dialogue)  # Debug print

# Set welcome state
func set_welcome_state(state: bool) -> void:
	welcome_completed = state
	print("Welcome state set to: ", welcome_completed)

# Set tutorial state
func set_tutorial_state(state: bool) -> void:
	tutorial_completed = state
	print("Tutorial state set to: ", tutorial_completed)

# Process input from the player
func process_input(event: InputEvent) -> void:
	# Check if tutorial is complete and disable dialogue triggering
	if tutorial_completed:
		set_can_trigger_dialogue(true) 
		return
	elif welcome_completed:
		set_can_trigger_dialogue(false)  # Disable dialogue during the tutorial
		return
	else:
		set_can_trigger_dialogue(false)


	# Track tutorial inputs if enabled
	if track_tutorial_inputs:
		if event.is_action_pressed("left"):
			required_keys_pressed["left"] = true
		elif event.is_action_pressed("right"):
			required_keys_pressed["right"] = true
		elif event.is_action_pressed("attacking"):
			required_keys_pressed["attacking"] = true


		# Check if all required inputs have been pressed
		if all_keys_pressed():
			end_tutorial()



# Ends the tutorial and starts the next dialogue
func end_tutorial() -> void:
	DialogueManager.show_dialogue_balloon(load("res://dialogues/teach.dialogue"), "proceed")
	ui_prompt.visible = false
	track_tutorial_inputs = false
	tutorial_completed = true
	dialogue_active = true


# Checks if all required keys/actions have been pressed
func all_keys_pressed() -> bool:
	for key in required_keys_pressed.keys():
		if not required_keys_pressed[key]:
			return false
	return true  # All required keys have been pressed

# Input function to capture player's input
func _input(event: InputEvent) -> void:
	process_input(event)

The way I typically handle something like this is to have a master scene (the game itself) and child scenes. The master scene normally handles all input.

When the master scene spawns the welcome or tutorial scenes (or other such major child scenes), I disconnect all the user input in the master scene, and have the child scene handle all input.

When the child scene exits, I reconnect all the user input in the master scene.

I don’t have scenes for the dialogues, I use an asset for my dialogues, they are all set up as custom dialogues files, I call them in parts in the code I want them to show, and the only scenes I have are the level (main scene) and the player. I have a global script because this asset requires global calls to it. my inputs are also separated, I have player inputs and F key input, F key input is not located in the player script, it’s on a dialogue script in a node2D (not a scene, it’s a node2D child of the level scene), and it only shows dialogues when pressing F. I tested if the asset is involved in a conflict with it, but it doesn’t because I can disable input in the process, the issue is that when doing it in process, it checks every frame, so I can’t even press F at the start, this is where I need to resolve the issue, I just got to find the right location and bool checks to disable input when tutorial starts, and before the tutorial, the input is enabled. all code I shared is related only to the F key and tutorial