How can I grant my Developer Product correctly?
Hello!
I'm having trouble getting my Developer Product to grant the product, in this case 100000 Points. When I test it in Studio, I can click on my Surface Gui to bring my shop screen up, I click on the product, "Purchase 100000 Points", the screen pops up to confirm the purchase...but then the Points aren't added. I receive this error:
23:22:41.888 - userId is not a valid member of BoolValue
I'm not sure why my userId is not valid, I've seen the script laid out this way elsewhere.
Also, when I do a local server test, my Screen Gui won't appear at all when I click it, same for when I upload my game to Roblox itself and try. Any thoughts?
Here's my code below for the developer product:
01 | local MarketplaceService = game:GetService( 'MarketplaceService' ) |
02 | local devproductid = 48677962 |
04 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
05 | for i, player in ipairs (game.Players:GetChildren()) do |
06 | if player.userId = = receiptInfo.PlayerId then |
07 | if receiptInfo.ProductId = = devproductid then |
10 | player.leaderstats.Points.Value = player.leaderstats.Points.Value + 100000 |
14 | return Enum.ProductPurchaseDecision.PurchaseGranted |
And then I have this code inside the Text Button, inside the Frame, inside my Screen Gui inside Starter Gui:
1 | local button = script.Parent |
2 | local devproductid = 48677962 |
4 | button.MouseButton 1 Click:connect( function () |
5 | game:GetService( 'MarketplaceService' ):PromptProductPurchase(game.Players.LocalPlayer, devproductid) |
Thank you!