How to use the High Level Networking Signals

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

I (thought) had followed the instructions here:

but I can’t for the life of me get the signals to work. I would like to make sure that the servers are working before I get any further in the project. So my question is how do you work with signals with an autoloaded script like this? I’ve only ever done signals through the godot UI.


Here’s my code in case you want to see it. Beware, it’s not awesome.

    extends Node

var UserIPAddress = ""
var UserPort = 31400
var PlayerCount = 4
var Nickname

var players = {}
var self_data = {name = "", position = Vector3(0,0,0)}

func _ready():
	get_tree().connect("player_connected", self, "_player_connected")
	get_tree().connect("player_disconnected", self, "_player_disconnected")
	get_tree().connect("connected_to_server", self, "_connected_ok")
	get_tree().connect("connection_failed", self, "_connected_fail")
	get_tree().connect("server_disconnected", self, "_server_disconnected")
func create_server(player_nickname): = player_nickname
	players[1] = self_data
	var peer =

func join_server(player_nickname): = player_nickname
	var peer =

func connected_to_server():
	players[get_tree().get_network_unique_id()] = self_data
	rpc('_send_player_info', get_tree().get_network_unique_id(),self_data)
	print("Successfully connected")
func player_disconnected():
	print("Player has left the lobby")

func player_connected():
	print('Player connected: ')

func connection_failed():
	print("connection failed")

func server_disconnected():
	print("Server Disconnected")
remote func _send_player_info(id,info):
	if get_tree().is_network_server():
		for peer_id in players:
			rpc_id(id, "_send_player_info", peer_id, players[peer_id])
	players[id] = info
	var new_player = load("res://Scenes/Player.tscn").instance() = str(id)
	new_player.init(, info.position, true)
remote func kickPlayer():
:bust_in_silhouette: Reply From: avnih

The names of the functions are wrong.
If you wrote

   get_tree().connect("connected_to_server", self, "_connected_ok")

then you name the func as

func _connected_ok():

and not

func connected_to_server():