c# connect a signal with parameters, connected function gets 0 value

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

I am trying to connect a signal to a method and I have successfully been able to connect the signal to the function, but when I try to print the parameter value it says it’s basically the zero value of whatever data type I tried.
Here’s what I tried:

startButton.Connect("pressed", startButton, nameof(this.startMenuPressed), new Godot.Collections.Array(){"start"});

and the function is as follows:

public void startMenuPressed(String buttonName){
        GD.Print($"name: {buttonName} name equal: {buttonName == "start"}");

I also tested buttonName == “” and it printed out to be true. How can I pass the string value to the function? I also tried instead of the “start” directly, having a String variable that was equal to “start” instead, same results.

:bust_in_silhouette: Reply From: wooshuwu

I figured out the problem was that the target object was wrong, instead of

startButton.Connect("pressed", startButton, nameof(this.startMenuPressed), new Godot.Collections.Array(){"start"});

it should be

startButton.Connect("pressed", this, nameof(this.startMenuPressed), new Godot.Collections.Array(){"start"});

Then it works as intended.