I am making a sword fighting game and I made a dev product shop (for swords, powerups, etc.) There's a glitch where the previously bought sword duplicates when buying another sword. Here's a small part of the code, it's just for one sword. NOTE: This isn't the full script!
if purchaseInfo.ProductId == 1016546798 then
local sword = game.ServerStorage.Swords.Darkheart
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
Note: The sword is only meant to be usable in a single server. The gamepass part is already done. Here's a video of the bug: https://www.youtube.com/watch?v=FPsKXGAuWhs&feature=youtu.be
EDIT: Here's the full script:
local marketPlace = game:getService("MarketplaceService")
marketPlace.ProcessReceipt = function(purchaseInfo)
local plr = game:getService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
if purchaseInfo.ProductId == 1016546798 then
local sword = game.ServerStorage.Swords.Darkheart
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016545986 then
local sword = game.ServerStorage.Swords:FindFirstChild("Illumina")
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016548359 then
local sword = game.ServerStorage.Swords.Firebrand
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016547469 then
local sword = game.ServerStorage.Swords.Venomshank
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016549468 then
local sword = game.ServerStorage.Swords.Icedagger
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016548880 then
local sword = game.ServerStorage.Swords.Ghostwalker
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
elseif purchaseInfo.ProductId == 1016547105 then
local sword = game.ServerStorage.Swords.Windforce
local swordClone = sword:Clone()
local swordClone2 = sword:Clone()
swordClone.Parent = plr.Backpack
swordClone2.Parent = plr.StarterGear
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted

3 comments
honestly i would put swords as a gamepass.
If you want us to help you, then you have to provide the full script
There you go!