Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Help with the develeopr product thing

Asked by 10 years ago

I went to the test place to try it out, and when I bought the sample product, it worked. So I created my own DP, and put the ID in the script. I joined a game, and when I clicked on the thing, and bought it, it said roblox was still doing maitmense on it. So... It was either that, or it was my coding.

-- setup local variables local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = "19320781"

-- define function that will be called when purchase finished MarketplaceService.ProcessReceipt = function(receiptInfo)

-- find the player based on the PlayerId in receiptInfo
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then

-- check which product was purchased
if receiptInfo.ProductId == productId then

-- handle purchase. In this case we are healing the player.
MorePoints = player.leaderstats.Credits + 100

-- more feedback for the player.
game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased a healing potion."
end
end
end 

-- record the transaction in a Data Store
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
ds:IncrementAsync(playerProductKey, 1) 

-- tell ROBLOX that we have successfully handled the transaction
return Enum.ProductPurchaseDecision.PurchaseGranted 

end

1 answer

Log in to vote
1
Answered by 10 years ago

Your code should be fine. PromptProductPurchase is working for me, try again.

0
It will wont work johnjohncar 10 — 10y
0
Where do you prompt the purchase? Articulating 1335 — 10y
0
I made the at one of my games. I'll give the link. I tried it again, and it worked, but it didn't give +100 Credits to my credits stats. http://www.roblox.com/Teston-place?id=146688974 johnjohncar 10 — 10y
0
Is 19320781 the correct product ID? Articulating 1335 — 10y
0
Yes. Its correct johnjohncar 10 — 10y
Ad

Answer this question