How could i make my button signal to different nodes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl

Greets!

Meaning i got a button wich once pressed should change scenes, and i want to use it with different CollisionShapes. Trouble is, it only change to the last scene signaled, not the one written in script.
How could i change that please?

Here’s the signal used to connect my Area2D/CollisionShape and their scripts:

func _on_Enter_pressed():
	get_tree().change_scene("res://Scenes/Gipsy-camp.tscn")

The name of the scenes are changed, but it only loads the last signalled one, whatever the name written.

It would be easier for us to understand your issue if you provided the code you are using.
You could edit your post and include snippets of the code. :slight_smile:

Mitcha47 | 2020-02-18 18:37

Ok, edited. Hope it’s enough, dunno what to add. :slight_smile:

Maybe a shot of my GUI buttons:

Imgur: The magic of the Internet

The ‘enter’ one is the greyed one.

Syl | 2020-02-18 20:23

:bust_in_silhouette: Reply From: Magso

If your script is on a parent of the buttons or the scene node, the signals can be connected per button.
If you’re using the one script on each button it would be easier to make a scene of the button and to make it a multipurpose button using an enum or bools to determine the button’s functionality, plus the connected signal would be relevant to the button instance that is clicked on. Here’s an example of an enum.

enum button_types { the,different,button,types }
export(button_types) var button_type = button_types.button

func _on_Enter_pressed():
    if button_type == button_types.button:
        //functionality

No, sry, got many same script from diferent node, but to the same button ‘enter’, with diferent scenes changed.

Syl | 2020-02-18 23:05