Problems with multiplayer

I was trying to test multiplayer in godot with a simple test, changing the ui in each player’s screen:
Here’s the @onready var label player script
extends CharacterBody2D

@onready var label = $Label as Label
var rng =
func _ready():
var my_random_number = rng.randf_range(-10.0, 10.0)
func _enter_tree():

func _physics_process(delta):
if is_multiplayer_authority():
velocity = Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”) * 400
And here its the lobby/world script where its the label from the previous code:
extends Node2D

var peer = #Creamos el Peer
@export var player_scene: PackedScene #Exportamos la escena jugador

func _on_host_pressed():
peer.create_server(135)#Puerto abierto
multiplayer.multiplayer_peer = peer #Establecemos el peer del multijugador
_add_player() #para que el host juegue

func _add_player(id=1):
var player = player_scene.instantiate()#Añadimos una instancia del jugador = str(id)
call_deferred(“add_child”, player) #Añadimos al jugador a la escena

func _on_join_pressed():
peer.create_client(“localhost”, 135)
multiplayer.multiplayer_peer = peer
How do i change the text with an unique random number in each player’s screen?
Also, how i could spawn the players in a new scene different from the lobby (they spawn in the menu with the button xd)

Can you please format the code with a code block?

" "Use spaces to show indentations.
Leading spaces don’t render outside of code block

    Leading spaces in code block
No leading spaces in code block
1 Like