Can't send 2 parameters using remote functions, the first one gets duplicated

Hi everyone! I’ve gotten stuck with a thing I’m making.
The objective is simple. I’m trying to send 2 parameters thought a remote function and receive them.

The problem it’s that the first one (player) is getting duplicated and overwrites the second one. And I don’t know what might be the cause.

Here’s the code where I’m calling the remote function (from a local script)

--Equip an specific item (there's no need to check locally, the check will be made on server)
function TryEquipItem(itemName: string, itemType: string, guiFrame: Frame)
	
	local itemsToWear = {
		["Animation"] = nil,
		["Skate"] = nil
	}
	
	if itemType == "Animation" then
		itemsToWear.Animation = itemName
	elseif itemType == "Skate" then
		itemsToWear.Skate = itemName
	end
	
	--Check if the player owns the item and wear them
	local result = SaveWearItems:InvokeServer(Players.LocalPlayer, itemsToWear)
	if result == false then
		return
	end
	
	local button = guiFrame.BarFrame["002-Buy-Equip-Button"]

	guiFrame.BarFrame["001-CostLabel"].Text = "Equipped"
	button.ModeValue.Value = "UnEquip"
	button.Text = "UnEquip"
end

As you can see, the remote function is called below the second comment. If i print “itemsToWear” I get that data correctly.

This is where the remote function is being called:

--Try wearing the items a player owns from their inventory
--TODO Call it when a player character respawns too
function TrySaveWearing(player: Player, itemsToWear)
	
	print(player, itemsToWear)
	
	local result = DatabaseModule.TrySaveWearingItems(player, itemsToWear)
	
	if result == true then
		--TODO
	else
		return false
	end
end

--Try to wear and save items for a player (callback)
SaveWearItems.OnServerInvoke = TrySaveWearing

The print of this second code returns 2 times the content of the player, instead of the player + itemsToWear dictionary:

image

I’m really stuck in this problem and I appreciate any help. Thanks :smiley:

Remove this from the InvokeServer. The player is already passed when invoking the server.

1 Like

the first variable of a remote is always the player that fires it by default so you don’t have to add it.

1 Like

Thank you guys, such a dumb thing. Didn’t know it :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.