I’m a scripter that can script many things on Roblox. However, I can’t seem to find a way to script developer products, and once someone buys it, it gives them points through their leader stats points. How do I accomplish this?
I’ve tried to read many sources such as developer.roblox.com and still confused about how to do it.
local MarketplaceService = game:GetService("MarketplaceService")
local Products = {
[0]=function(receipt,player) --product id here
player.leaderstats.Gems.Value = player.leaderstats.Gems.Value + 5
end;
}
function MarketplaceService.ProcessReceipt(receiptinfo)
local playerProductKey = receiptinfo.PlayerId..":"..receiptinfo.PurchaseId
local plr = game:GetService("Players"):GetPlayerByUserId(receiptinfo.PlayerId)
local handler
for ProductId,func in pairs(Products) do
if ProductId == receiptinfo.ProductId then
handler = func break
end
end
local suc = pcall(handler,receiptinfo,plr)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for prompt
local productId = 0 --id
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
You should consider taking a look at the .ProcessReceipt function of MarketPlaceService. This method fires after a developer product has been bought. Using this method you could, for instance, add points to a leaderboard. It has a really great example script that should be relatively easy to use.