Linking Signals and variables from a Scene A to an instance of a Scene B

Godot Version 4.1

Hello there, i’m posting here since i’ve been struggling looking for answers to my problem that i couldn’t find here, so here i go. I’m currently deving a mechanic that would be similar to a rythm game, for now i got notes that pops up and that go left.
They are being instanced in a bar that contains colliders for where is the note when hit. Tho by trying to dev this mechanic i knew i would need the use of signals and variables that are not in the main scene.

For example lets take my Canvas_layer which is where i store the HUD and so the main mechanic. we’ll call it scene1

And on the other side we got the little notes that pops up, they are a separated scene from scene 1, they are in the project but in another scene, they just get instanced to scene 1. the script to pop them up is introduced like so (i cutted parts of my script just to get the main thingy) :

(Script of scene1)

extends CanvasLayer

var BPM = 200
@export var BPMtotal = 60.0/BPM
var RythmMark = load("res://HitNote.tscn")

func _ready():
	var BPMVarTimer = $"Until something respawns"
	BPMVarTimer.wait_time = BPMtotal

func _on_until_something_respawns_timeout():
	var rythmnote = RythmMark.instantiate()
	rythmnote.position.x = $GNSP.position.x
	rythmnote.position.y = $GNSP.position.y

Lets take the child being added, rythmnote(scene2), i want to add a value to an inner variable from rythmnote and use his signals directly into the script of my main scene

for example in my rythmnote, i want to change the parameter "@export var location = 0" of it directly from the script of Scene1 when it touches one of the area2d of my rythmBar

for example

func _when_area2D_touched():
        instance.location = 1

-just an example

but i encountered the several problems which are not being possible to access a variable that is in a function and also using a function in a function, so honnestly i am lost… i’ve tried instance.connect but it doesn’t seem to change anything to my script…

also i would like to know how to access a signal from the instance of scene2 directly from scene1

Thanks to the one who’ll answer i’ve been searching for 3 days. Have a good day/night ! covers the exact issue you’ve written about in the title.

You need to create a custom signal in the scene that has access to the thing you want and emit it there, have it caught by the other scene and read the value as an argument passed into the signal.

Please format your code next time using the “Preformatted text </>” icon next time as it makes it harder to read without it.

Can you do something with this example?

extends Node2D
class_name ClassA

signal eventA(value: int)

func _ready():
	print("ClassA _ready")

extends Node2D
class_name ClassB

signal eventB

func _ready():
	print("ClassB _ready")
	var classA : ClassA =

func _event_classA(value):
	print("_event_classA, value = ", value)

add “ClassB”- Scene/GdScript to Main-Scene


ClassB _ready
ClassA _ready
_event_classA, value = 10