--SET UP VARIABLES-- local MarketPlace = game:GetService("MarketplaceService") local Datastore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") DamageID = 19312506 -------------------- script.Parent.MouseButton1Down:connect(function() MarketPlace.ProcessReceipt = function(receiptinfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptinfo.PlayerId then if receiptinfo.ProductId == DamageID then player.Character.Humanoid.Health = player.Character.Humanoid.Health - 20 script.Parent.Text = player.Name .. " has bought death ! " end end end local productplayerkey = "player_" .. receiptinfo.PlayerId .. "_purchase_" .. receiptinfo.PurchaseId DataStore:IncrementAsync(productplayerkey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end end)
I'm having a similar problem but I believe I know how to fix this.
I'm pretty sure that the ProcessReceipt function should be in a separate script somewhere. Your going to need to use PromptProductPurchase(player, ID)
instead of simply calling the Receipt function when the player pushes the button.