Remotefunction muliplies print/number and doesn't work

i have a problem using a remotefunction i don’t know anything to do to prevent this here’s the example:

image

here’s the code:

client:

	Drop.MouseButton1Click:Connect(function()
		print("Dropping")
		ReplicatedStorage.Remotes.DropPlayerItem:InvokeServer(Drop.Name)
		Info.Visible = false
		print("end")
	end)

server:

remotes.DropPlayerItem.OnServerInvoke = function(Player, DropName)
	print("Works!")
	local Drop = ReplicatedStorage.Assets.Drops:FindFirstChild(DropName)

	if Drop then
		Player.Materials[DropName].Value -= 1
		print(Player.Materials[DropName].Value)
	end
end

thank for the collaboration! :wink:

Hard to solve this without further information such as full code samples? Also, since your remote signal doesn’t return anything, why are you using a function instead of an event?

I’m guessing it’s not the remote function multiplying but the mouse button click connection that is multiplying.

Connection seems to be indented in another function so you should probably show the full script.

1 Like

By the way, you should be using RemoteEvents. Only use RemoteFunctions if you’re returning a value.

The drop count going up by 1 with each click suggests that somewhere in your code you’re creating a new on click binding that calls the remote function. Put a debug print statement, ideally with a debug.traceback(), where you connect up the MouseButton1Click binding, and see why it’s getting called when you click.

2 Likes

im using a remote function because i need the info to go from client to the server so other players can see what the player has dropped: ooga booga (reborn) drop mechanic

this can be helpful but idk what are you saying because idk how to do it can you give some code for example?

at the end i was dumb because this:


			local ExistingSlot = Inventory.MainFrame.ScrollingFrame:FindFirstChild(Material.Name)
			
			if ExistingSlot then
				if Material.Value == 0 then
					ExistingSlot:Destroy()
				else
					ExistingSlot.TextAmount.Text = "X"..Material.Value
				end
			else
				local Slot = CreateSlot(Material)
				Slot.MouseButton1Click:Connect(function()
					print("clicked")
					ShowInfo(Slot) -- at the end the thing was creating a 
					--new mouse1click every time this function was called
				end)
			end

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