Getting non fatal error on connect - "The function 'connect()' returns a value, but this value is never used. "

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

Very simple program using

func _ready():
get_node(“…/Button”).connect(“pressed”, self, “_Button_Pressed”)

gives me the above error. It’s not fatal but it is annoying if you have OCD :slight_smile:

Anyway to get rid of this besides giving it a dummy variable that will not be used and will probable cause another similar error?

Thanks

:bust_in_silhouette: Reply From: njamster

connect is returning an Error-enum, so the proper way would be:

var error = get_node("../Button").connect("pressed", self, "ButtonPressed")
if error:
    print("Connect failed")

You can disable certain warnings under Project Settings > Debug > Gdscript, though I wouldn’t recommend that. These warnings exist for a reason.

Perfect thanks!

thinkingfield | 2020-02-09 16:55