[SOLVED] Why do I get multiple M1911s...?
The pictures explain most of it...
First Picture (Lightshot),
Second Picture (Also Lightshot),
Third Picture (Yet Again, Lightshot)
So I really need help figuring out why I receive a random number of M1911's when I purchase the Developer Product.
+Rep to anyone who helps me, with logical/working answers.
If you don't feel like looking at the pictures (even though they explain everything better...),
Here is the LocalScript inside StarterPack:
01 | local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton |
02 | local damageButton = game.Workspace.DamageButton.SurfaceGui.TextButton |
03 | local productId = 19635648 |
05 | buyButton.MouseButton 1 Click:connect( function () |
06 | game:GetService( "MarketplaceService" ):PromptProductPurchase(game.Players.LocalPlayer, productId) |
09 | damageButton.MouseButton 1 Click:connect( function () |
10 | game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.Health - 40 |
Here is the Script inside Workspace.BuyButton:
01 | local MarketplaceService = Game:GetService( "MarketplaceService" ) |
02 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
03 | local productId = 19635648 |
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 | game.Lighting:FindFirstChild( "M1911" ):Clone().Parent = player.Backpack |
13 | game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased an illegal M1911." |
15 | weapons = game.Lighting:FindFirstChild( "M1911" ) |
16 | local c = game.Players:FindFirstChild(player.Name).Backpack:GetChildren() |
19 | if c [ i ] .Name ~ = "M1911" then |
21 | for i = 1 , #weapons do |
22 | if weapons [ i ] .className = = "Tool" then |
23 | weapons [ i ] :clone().Parent = player.Backpack |
31 | local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId |
32 | ds:IncrementAsync(playerProductKey, 1 ) |
34 | return Enum.ProductPurchaseDecision.PurchaseGranted |