Why is this spam firing the remote?

I would like the remote to not spam fire. How will I go about this?

The code:

	infoUI.Equip.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.Equip:FireServer(itemSelected.ItemId);
		itemSelected.Equipped = not itemSelected.Equipped
		if itemSelected.Equipped == true then
			infoUI.Equip.Text = 'Unequip';
		else
			infoUI.Equip.Text = 'Equip';
		end
	end)

I tried adding a debounce on the remote itself, but it still fires consistently anyway so eventually it stops datastore request and errors, and creates data loss. Please help. If you need any more code from my system, I am willing to provide it.

Edit: I added a return and a client sided debounce, it still spam fires, just doesn’t lag the client. Any fix this time?

Limit the amount of requests made by this remote on the server and also add the debounce of the client side.

1 Like

Thank you. This worked. I also added a return afterwards, and it re-runs the main function (so they can reclick lock or equip). Much appreciated.

1 Like

I added a return and a client sided debounce, it still spam fires, just doesn’t lag the client. Any fix this time?