extends Node const PLAYER = preload("res://player/Player.tscn") func _ready(): %Network.add_handler(%Network.Packet.LOGIN, self) send_login() func send_login(): var buffer := StreamPeerBuffer.new() buffer.put_8(%Network.Packet.LOGIN) buffer.put_data("password".to_utf8_buffer()) %Network.udp.put_packet(buffer.data_array) print("Connecting...") func handle_packet(data: PackedByteArray): if data[1] != 0: print("Login failed.") return print("Login succeeded.", data) spawn_player() func spawn_player(): var player = PLAYER.instantiate() add_child(player)