Hello, I am having problem with Developer Product - the purchase pop-up does work and completed, but the problem I am having that the Leaderboard is not changing it's value.
Another words: The purchase thing works - just that the Leaderboard doesn't update the Coins after purchase.
Can anyone help me with the scripting???
Here is the part of the script that doesn't work.
mps.ProcessReceipt = function(info) local plr = tonumber(getPlayerById(info.PlayerId)) if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5 end end
Here is a full script.
local buyButton = script.Parent local productId = 19187415 local mps = game:GetService"MarketplaceService" function getPlayerById(id) for i,v in pairs(game.Players:GetPlayers()) do if v.userId == id then return v end end end buyButton.MouseButton1Click:connect(function() mps:PromptProductPurchase(game.Players.LocalPlayer, productId) end) mps.ProcessReceipt = function(info) local plr = tonumber(getPlayerById(info.PlayerId)) if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5 end end
developer products are very annoying, i got'it fixed after around 15 tries, here's the script ;)
local MarketplaceService = game:GetService("MarketplaceService") local ProductID = DEVELOPER PRODUCT ID HERE MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == ProductID then --Do stuff here end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
What about this? I tried the script above, but it doesn't work! Does this part of the script that needs changing?
Script Line:
buyButton.MouseButton1Click:connect(function() mps:PromptProductPurchase(game.Players.LocalPlayer, productId) end) mps.ProcessReceipt = function(info) local plr = tonumber(getPlayerById(info.PlayerId)) if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5 end end