Online Multiplayer - Error when queue_free() player

Okay here’s the best way I found to remove a node that is auth’d to the client without any debug errors. See code below.

Globals.player_lives1 is synced with a MultiplayerSynchronizer in the client player scene.

when the client player dies:
1)first the client toggles off the public_visibility on the MultiplayerSynchronizer in the client player scene- this fixes the common “node not found” error
2)then the server queue_free()'s the client player scene - this avoids any despawn errors


@onready var multiplayer_sync = $MultiplayerSynchronizer

func _process(delta)

	if Globals.player_lives1 < 0:
	
		#client has to toggle off multiplayer synchronizer to avoid debug error
		if owner_id == multiplayer.get_unique_id():
			multiplayer_sync.public_visibility = false
				
		#then server has to queue_free() to avoid debug error
		if !multiplayer.is_server():
			return
		queue_free()
2 Likes