Added an if not statement to check if that tool is already in the Backpack. That way it will prevent the player from having multiple copies of Obitor.. or whatever that is lol.
01 | local MarketplaceService = Game:GetService( "MarketplaceService" ) |
02 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
03 | local productId = 19645570 |
05 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
07 | for i, player in ipairs (game.Players:GetChildren()) do |
09 | if player.userId = = receiptInfo.PlayerId then |
11 | if receiptInfo.ProductId = = productId then |
12 | if not player.Backpack:findFirstChild( "Obitor" ) then |
13 | game.Lighting:FindFirstChild( "Obitor" ):Clone().Parent = player.Backpack |
14 | game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased an illegal Obitor." |
19 | local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId |
20 | ds:IncrementAsync(playerProductKey, 1 ) |
22 | return Enum.ProductPurchaseDecision.PurchaseGranted |