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

Coins dev product wont work?

Asked by 5 years ago
Edited 5 years ago

I have Two scripts that are suppose to make it so when you click a button it will ask if you want to buy something(with robux), and and when you click to buy it it will add to a leader stat(for the person who bought it).

this script is in ServerScriptService:

local MarketplaceService = game:GetService('MarketplaceService')
local devProductid = 391839362
MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in pairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value +100 
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

This is in the text button:

local devproductid = 391839362
local button = script.Parent
button.MouseButton1Click:Connect(function()
    game:GetService('MarketplaceService'):PromptProductPurchase(game.Players.LocalPlayer, devproductid)
end)
1
Make sure there are no other scripts using ProcessReceipt like a donation board. popeeyy 493 — 5y
1
You know Players:GetPlayerByUserId exists right? No need to loop through the players. Use GetPlayers and not GetChildren anyways. Also userId is deprecated, use UserId. User#19524 175 — 5y

Answer this question