When I purchase a developer product in my game it gives me the receipt and everything however it doesn't give me the popcorn/product. What is wrong with my script?
local MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.ProcessReceipt = function(receiptInfo) local players = game.Players:GetPlayers() for i=1,#players do if players[i].UserId == receiptInfo.PlayerId then local RS = game:GetService("ReplicatedStorage") local item = RS:WaitForChild("Popcorn") local cloned = item:Clone() local player = game.Players:GetChildren() cloned.Parent = player.Backpack cloned.Parent = player.StarterGear print("cool") end end return Enum.ProductPurchaseDecision.PurchaseGranted end
:GetChildren() returns an array of all children of an object. Basically, the player variable was not the player but all of them.
local MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.ProcessReceipt = function(receiptInfo) local players = game.Players:GetPlayers() for i=1,#players do if players[i].UserId == receiptInfo.PlayerId then local RS = game:GetService("ReplicatedStorage") local item = RS:WaitForChild("Popcorn") local cloned = item:Clone() local player = players[i] cloned.Parent = player.Backpack cloned.Parent = player.StarterGear print("cool") end end return Enum.ProductPurchaseDecision.PurchaseGranted end