High Level Multiplayer error with unknown reason

Godot Version

Godot 4

Question

Hey everyone, hello, hoping you are having a good day.
I was playing around with godot’s High Level multiplayer system.
And i keep gettin an error spammed on console till the program’s running:

E 0:00:00:0772   multiplayer_spawner.gd:12 @ _process(): Signal 'peer_connected' is already connected to given callable

The code of the script is:

extends MultiplayerSpawner
@onready var label: Label = $"../Label"


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	multiplayer.peer_connected.connect(print_join)

func print_join(id: int) -> void :
	if !multiplayer.is_server(): return
	label.text = "Someone joined"

I was looking on this tutorial just to get a slight understandment of the whole thing, and the dude on the video did kind of the same thing, but used it to spawn players instead, while i just used it to set a label’s text

the only other script is

extends Node

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass



func _on_clientstarter_pressed() -> void:
	var peer = ENetMultiplayerPeer.new()
	var PORT = 42690
	var IP_ADDRESS: String = "localhost"
	peer.create_client(IP_ADDRESS, PORT)
	multiplayer.multiplayer_peer = peer


func _on_serverstarter_pressed() -> void:
	var peer = ENetMultiplayerPeer.new()
	var PORT = 42690
	var MAX_CLIENTS = 32
	peer.create_server(PORT, MAX_CLIENTS)
	multiplayer.multiplayer_peer = peer

it just starts server and client respectively through buttons in a scene with just 2 buttons and a label.

Sorry for my english, it’s not my native language, hope I can understand the reason of the error and how i can do this properly.

_process is called every frame so you are trying to make a new connection to this signal every frame, but are only allowed to make one connection per callable. Chances are you ment to put this under _ready instead as it is only called once.

3 Likes

Yeah really my bad for not thinking about the fact that multiplayer.peer_connecyed is a signal
makes sense thank you.