Your script would error, to fix this figure out where the cash is.
This is the server's side of the script.
function CompletePurchase()
game.Players.LocalPlayer = game.Players.LocalPlayer + 10
end
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 23429504
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productId then
CompletePurchase()
end
end
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Here's the player's side:
local buy = script.Parent
local productId = 23429504
buy.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
I will say that I don't know where the BuyButton is, so you'll have to change buy to where its at. The server's side goes in the model. The player's side goes in a local script in the StarterPack and possibly in the model in which that may make it even easier. Tell me if there's any errors.
4 comments
Code block please
fixed
I believe you shouldn't be activating what will happen with the Product in the Client script. Do it within your Server Sided. Look at Uristmcsparx example for ROBLOX Wiki
@alpha, he's not defining the ProcessReceipt in his localscript, so it's fine. The ProcessReceipt is what controls what happens when someone purchases a Developer Product. If he were then that would be a problem, but he's not.