uglypoe
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 4382 |
|
|
| 11 Jul 2014 08:39 PM |
This is a script inside of a textbutton. What I want is for, when you click the textbutton, for a developer product prompt to show up, but it doesn't seem to. The in-game developer console says "MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type nil".
local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 20394594 local Buy = script.Parent
Buy.MouseButton1Down:connect(function(PromptProductPurchase) MarketplaceService:PromptProductPurchase(player, productId) end)
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productId then
player:findFirstChild("Stats").Credits.Value = player:findFirstChild("Stats").Credits.Value + 10
end end end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted end |
|
|
| Report Abuse |
|
|
uglypoe
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 4382 |
|
| |
|
uglypoe
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 4382 |
|
| |
|
|
| 14 Jul 2014 06:59 PM |
local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 20394594 local player = game.Players.LocalPlayer -- maybe? local Buy = script.Parent
Buy.MouseButton1Click:connect(function() MarketplaceService:PromptProductPurchase(player, productId) end)
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productId then
player:findFirstChild("Stats").Credits.Value = player:findFirstChild("Stats").Credits.Value + 10
end end end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted end |
|
|
| Report Abuse |
|
|