Items duplicate more than one!


So I tryed to fix a bug on my friends game that duplicated an item.

However the issue is that now there are 3 items than just 1! It’s too annoying!

Here are the scripts:

The LocalScript when the ImageButton is clicked.
local ReplicatedStorage = game.ReplicatedStorage
local crimsoncola = ReplicatedStorage.CrimsonCola

The script in ServerScriptService (Yes for each item 1 event is used at once with a tag for the item.)
local ReplicatedStorage = game.ReplicatedStorage

game.ReplicatedStorage.ItemEvent.OnServerEvent:Connect(function(player, item)
	item:Clone().Parent = player.Backpack

Any help will be appriciated. Thanks!

Sorry for the lack of what’s happening!

NEW: I forgot to mention that when the script was in the ImageButton it duplicated once. But now it duplicates two times!

print something in both scripts to see which one is having the issue

But what exactly? I can’t I don’t know what to print!

just print in the local script “Event Fired” and in the Server Script “Event Recieved” or something similar because maybe you are firing the remote multiple times

None of them are have (4x) (Now it’s duplicating it 3 times for a reason.)

NEW: I clicked on the coffee and it printed out Event Recieved! even though the main thing I put the print on was the Crimson Cola.

i replicated your scripts and its working just fine

Check this out then.

game.ReplicatedStorage.ItemEvent.OnServerEvent:Connect(function(player, item)
	if player.Backpack:FindFirstChild(item.Name) or (player.Character and player.Character:FindFirstChild(item.Name)) then return end
       item:Clone().Parent = player.Backpack

this code basically says, if the player’s backpack has the tool of whatever name you wanted to give them, or if their character is currently holding the tool you wanted to give them, then exit out of the fucntion and do not give them a second one. essentially making it so you cannot have more than 1 at all times

You only lowered the number by one. It still duplicates.

do you have any external script that may be causing this issue?

Do you have multiple tools that fire different parts to the server?

1 Like

i think i solved it, you currently are using 4 Server Scripts, One for each item, you only need 1 as the rest are also getting the event, causing it to clone 4 times, only keep 1 of those 4 and it should work perfectly with every item!