I'm working on a PlayerPoints shop, where you can buy player points with Robux. For some reason, the script errors out in game. Can anyone figure out what is wrong? Thanks.
local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local points = game:GetService("PointsService") local twoPoints = 19642067 local fivePoints = 19642318 local tenPoints = 19642331 local fiftyPoints = 19642337 local hundredPoints = 19642339 MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == twoPoints then points:AwardPoints(player.userId, 2) elseif receiptInfo.ProductId == fivePoints then points:AwardPoints(player.userId, 5) elseif receiptInfo.ProductId == tenPoints then points:AwardPoints(player.userId, 10) elseif receiptInfo.ProductId == fiftyPoints then points:AwardPoints(player.userId, 50) elseif receiptInfo.ProductId == hundredPoints then points:AwardPoints(player.userId, 100) end end end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
Well, I am working with my own Developer Products right now and here is my script (It works entirely, except that it gives multiple M1911s instead of just one for some reason...)
local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 19635648 MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == productId then game.Lighting:FindFirstChild("Obitor"):Clone().Parent = player.Backpack game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased an illegal M1911." end end end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
Is it possibly because you have it awarding points? That's probably why.
Also, what is the output errors?
local MarketplaceService = Game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId
-- ...
-- use DataStore to record purchase
-- ...
return Enum.ProductPurchaseDecision.PurchaseGranted
end
or
local MarketplaceService = Game:GetService("MarketplaceService") local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local productId = 13672652
buyButton.MouseButton1Click:connect(function() MarketplaceService:PromptProductPurchase(player, productId) end)
or go here:
http://wiki.roblox.com/index.php?title=Special%3ASearch&profile=default&search=MarketPlace+Service&fulltext=Search