Multiplayer game not working!!!

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

HEY!! i’m very new to networking and tried making a multiplayer game, I followed a tutorial on youtube this is what i ended up with i’m sure you can spot very clear errors if you do please tell me!!
here are the problems i encountered:

-the client doesn't see the host 
-the host sees the client but it controls it too (and it has the same name too)

here’s my code in my file:

extends Node

var SERVER_PORT = 31899
var SERVER_IP = ""  #

var players = { }
var self_data = { name = "", posiiton = Vector2(360, 180) }

func _ready() -> void:
	get_tree().connect("network_peer_disconnected", self, "_player_disconnected")

func CreateServer(player_nickname): = player_nickname
	players[1] = self_data
	var peer =
	peer.create_server(SERVER_PORT, MAX_PLAYERS)

func JoinServer(player_nickname): = player_nickname
	get_tree().connect("connected_to_server", self, "_connected_to_server")
	var peer =
	peer.create_client(SERVER_IP, SERVER_PORT)

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)

func _player_connected(id):
	print("Player connected" + str(id))

func _player_disconnected(id):
	print("Player disconnected" + str(id))

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://entity/player.tscn").instance() = str(id)

func update_position(id, position):
	players[id].position = position 
:bust_in_silhouette: Reply From: Emmabelotti

have you followed this guide? if so, check the demo project, it has some hidden scripts. You should start the networking script as an autoload and also spawn a player via your “world” script (it’s shown in the tutorial for a brief moment). If it doesn’t work and the networking script is the same as the tutorial’s one, then your player code has some errors