Hslider value changed signal is not working, gives error

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

I’m using the script below to connect to the value_changed() signal of a HSlider.

func _ready():
	self.connect("value_changed", self, "_on_changed")

func _on_changed():
	print("value changed to " + str(value))

but when play the scene and drag the slide I receive this error in the debugger:

E 0:00:02.824 emit_signal: Error calling method from signal ‘value_changed’: ‘HSlider(SoundIconSet.gd)::_on_changed’: Method expected 0 arguments, but called with 1…
<C++ Source> core/object.cpp:1228 @ emit_signal()

please advise.

:bust_in_silhouette: Reply From: d.dastan

After a bit of trial and error, and more studying I realized my mistake.
the value_changed signal sends a value which _on_changed() function needs to receive.

this fixed the problem:

func _ready():
    self.connect("value_changed", self, "_on_changed")

func _on_changed(v):
    print("value changed to " + str(v))

the argument v is the amount sent by value_changed