Issue with removing nodes spawned with multiplayer spawners

4.6 beta 2

My current goal is to try to make it so you can change the weapons a player is holding (loadouts), and the remote clients will see the new weapons.

Currently I am having issues trying to delete nodes spawned with a multiplayer spawner. At the moment, delete weapons is called for every player. In the script below, the host player (server) doesn’t see anyones weapons after the delete weapons function is called. The remote clients also do not see the hosts weapons, but they still have their own (only on their client though).

func delete_weapons():
	if multiplayer.is_server():
		for c in camera.get_children():
			c.call_deferred("queue_free")

func swap_weapons(weapons : Array) -> void: #basically add weapons
	if is_multiplayer_authority() or get_tree().current_scene.name == "Practice":
		var weapon_number := 1
		var weapon
		for w in weapons:
			match w:
				"glock19": weapon = GLOCK_19.instantiate()
				"sniper": weapon = SNIPER.instantiate()
				"shotgun": weapon = SHOTGUN.instantiate()
			weapon.hotkey = weapon_number
			weapon_number += 1
			camera.call_deferred("add_child", weapon)

I have also tried making it so the server instantiates weapons for every player, but that ended up with remote peers not having their own weapon on their client (while being able to see the hosts, and the host seeing everyones weapons). (Script below)

func delete_weapons():
	if multiplayer.is_server():
		for c in camera.get_children():
			c.call_deferred("queue_free")

func swap_weapons(weapons : Array) -> void: #basically add weapons
	if is_multiplayer_authority() or get_tree().current_scene.name == "Practice":
		rpc("_swap_weapons",weapons)

@rpc("any_peer","call_local")
func _swap_weapons(weapons : Array) -> void:
	if multiplayer.is_server():
		var weapon_number := 1
		var weapon
		for w in weapons:
			match w:
				"glock19": weapon = GLOCK_19.instantiate()
				"sniper": weapon = SNIPER.instantiate()
				"shotgun": weapon = SHOTGUN.instantiate()
			weapon.hotkey = weapon_number
			weapon_number += 1
			camera.call_deferred("add_child", weapon)

I have also tried making it so the remote clients queue free / remove child their own weapons after the server has gotten rid of all of them, but that ends up with the remote client being unable to see anything anyone else is doing (players multiplayer synchronizer stops working, but rpc’s still work fine). It doesn’t even give any errors.

I fixed the issue by setting the multiplayer authority of the weapons multiplayer spawner to the server, and making the server spawn the weapons. Then I made it so that the server deletes weapons too.