Topic was automatically imported from the old Question2Answer platform.
Asked By
Tjoeser
i’m trying to make a multiplayer game.
I got an error saying.
W 0:00:00.377 The function ‘connect()’ returns a value, but this value is never used.
<C++ Error> RETURN_VALUE_DISCARDED
That’s a Warning rather than an Error. Essentially, the connect() function returns a Error enum (defined here) that tells you whether your call to connect was successful or not.
In the case of your code, your not storing or using that return value and Godot is informing you of that.
To store / use it, you’d do something like this:
var err = get_tree().connect("networkpeerconnected", self, "playerconected")
if err != OK:
# connection failed - do something
You don’t have to store/use that value - so what you’ve done is perfectly valid. You could do any of:
Simply ignore the warning
Store / use the return value as above
Tell Godot to stop generating that specific warning or that class of warnings