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

How do you make it so when you purchase a dev product your money goes up?

Asked by 5 years ago

I created a script so when you purchase a dev product it gives you 1,000 cash but when I purchase it, nothing happens. How would I fix this? Also, I'm not getting any errors.

local MarketplaceService = game:GetService("MarketplaceService")
local devproductid = 437840868

MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductID == devproductid then
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000
            end
        end
    end
end
0
Either try capitalizing the I in id and p in product because that has happened to me in some cases where I forgot to capitalize D3VRO 66 — 5y
0
yes, case does matter SteamG00B 1633 — 5y
0
it already is TypicallyPacific 61 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

Use this script instead:

local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 437757000 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 50000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756922 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 10000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756846 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 5000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756738 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 1500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756644 then -- replace with your ID here -----------------------
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756559 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 100
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end
0
THank you sO MUCH THIS HELPED ME IN MY GAME TYSM UR THE BEST OMG Rynappel 212 — 4y
Ad

Answer this question