Item gets cloned multiple times

Whilst cloning tools inside of an admin UI I’m making, it clones the item multiple times. Any idea why?

local script -

script.Parent.TextButton.MouseButton1Up:Connect(function()
	local ToolGiven = script.Parent.Name
	local PlayerSelected = script.Parent.Parent.Parent.Parent.BackgroundScroller.SelectedPlayer.Value
	game.ReplicatedStorage.GiveTool:FireServer(PlayerSelected, ToolGiven)
end)

game.ReplicatedStorage.GiveTool.OnClientEvent:Connect(function(ToolGiven)
	if game.Players.LocalPlayer.Backpack:FindFirstChild(tostring{ToolGiven}) then
		game.Players.LocalPlayer.Backpack:FindFirstChild(tostring{ToolGiven}):Destroy()
	end
	
	local a = game.ReplicatedStorage.Tools:FindFirstChild(tostring(ToolGiven)):Clone()
	a.Parent = game.Players.LocalPlayer.Backpack
end)

server script -

game.ReplicatedStorage.GiveTool.OnServerEvent:Connect(function(player, PlayerSelected, ToolGiven)
	game.ReplicatedStorage.GiveTool:FireClient(game.Players[tostring(PlayerSelected)], ToolGiven)
end)
1 Like