How to fix "Trying to call an RPC via a multiplayer peer which is not connected."

Godot Version

Godot 4.2

Question

I am writing an online multiplayer game and am getting this error when I try to call an RPC function. This is the function that is resulting in the error:

@rpc("any_peer", "call_local", "reliable")
func load_players() -> void:
	# Check available colours
	for colour: Color in GlobalVars.joined_players:
		colour_picker.reserve_colour(colour)
	
	# Create the players
	for person: int in GlobalVars.joined_players.keys():
		# Create a player
		var new_player: Node = player.instantiate()
		
		# Set the player's device id
		new_player.device = person
		
		# Set the player's colour
		new_player.colour = GlobalVars.joined_players[person]
		
		# Set the player's multiplayer id
		new_player.multiplayer_id = multiplayer.multiplayer_peer.get_unique_id()
		
		# Set the name of the player node
		new_player.name = str(new_player.device) + str(multiplayer.multiplayer_peer.get_unique_id())
		
		# Put the players into the game
		$Players.add_child(new_player)

I do not understand what the error means let alone how to fix it, any help would be greatly appreciated, if it is required I can upload my project or gather other system information.