When you say that the button and the area are in two different scenes, where do they exist in your game's main scene?
I presume the node structure of your game's main scene looks like this:
- Main scene
- Scene with button
- Scene with area
If this is the case, what you should do is attach a script to the scene with the area. Give this scene's script a signal; I will call it "areaentered" as an example. Connect the area's area_entered
signal to a method in this scene's script, where you emit the script's "areaentered" signal.
# SceneWIthArea.tscn
extends Node
signal area_entered
func _on_Area2D_area_entered(_area: Area2D) -> void:
emit_signal("area_entered")
Next, attach a script to the main scene. With the scene with the area, connect its "area_entered" signal to a method in the main scene. In this method you can access the scene with the button, where you'd disable the button.
# Main.tscn
extends Node
onready var scene_with_button = $SceneWithButton as Node
func _on_SceneWithArea_area_entered() -> void:
var button := scene_with_button.get_node("Button") as Button
button.disabled = not button.disabled
Does this accurately address your code and the problem you are facing?