Why is my player 1 not player 1 for player 2

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

I know that the title is a little ambiguous so let me try to explain with images.

I’m basically trying to set up a multiplayer server where up to 6 people can play together P2P, with on player serving as the server. For my example, I will just demonstrate 2 players.
When players are in and the “START BUTTON” is pressed, they all spawn in. The picture on the left is the server, who I gave the name “Player1”, while the picture on the right is the client who I gave a name of “Player 2”. Note that I don’t have any function that iterates the number at the end, which could possible be causing the error, thus they could be named “Steve” and “Henry”

As you can see, player 1 and player 2 are different for the server vs client. When I try to move them, moving is shown in both the server and the client. HOWEVER, when I try to move them, only “player1 in server/player2 in client” would move as seen below.

The code I used for this project was highly based upon the Multiplayer Bomberman demo in Godot. When I press the start button, the following code will run.

This is the code that runs the moment you switch scenes.

Can anyone assist me with this issue? I’m pretty new to networking in Godot and I’ve been stuck for quite some time on this already.

:bust_in_silhouette: Reply From: lewis glasgow
func _ready():

or when a new player enters the game

for i in range(get_tree().get_network_connected_peers().size()):
    #		assuming that you set the player's node name to the peer id
    		if name == str(get_tree().get_network_connected_peers()[i]):
    			name_tag = i
    			rpc("set_name",name_tag)
    
    remote func set_name(n):
    	name_tag = i