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

How would you make a product to skip more than one stage? (Obby)

Asked by 1 year ago

Hello, I'm making a obby type game with a shop gui where you can buy products to skip either one, five or ten stages. The problem is the script to skip one stage works but it doesn't work to skip 5 stages. My local scripts to prompt the purchase to the player work but for some reason when I try to add more than one stage to the player leaderstats value it doesn't work. I would be so thankful if y'all can help me. (code below

Here's the server side script to skip one stage product (working) :

local marketPlaceService = game:GetService("MarketplaceService")

marketPlaceService.ProcessReceipt = function(receiptInfo)
    local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)

    if receiptInfo.ProductId == 1337983530 then
        player.leaderstats:FindFirstChild("???? Stage").Value += 1
        wait(1)
        player:LoadCharacter()
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

And here is the server side script for the skip five stages product (not working) :

local marketPlaceService = game:GetService("MarketplaceService")

marketPlaceService.ProcessReceipt = function(receiptInfo)
    local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)

    if receiptInfo.ProductId == 1339759965 then
        player.leaderstats:FindFirstChild("???? Stage").Value += 5
        wait(1)
        player:LoadCharacter()
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

Thanks in advance, ASE.

0
Btw, it doesn't even add on the leaderstats when you buy the skip 5 stages product neither does it reload the character, it just doesn't do anything unlike the "skip one stage" ssj_ase 0 — 1y
0
Still stuck with that, I thought I succeded to fix it but now the skip five stages works but not the ten one ssj_ase 0 — 1y

1 answer

Log in to vote
0
Answered by
9mze 193
1 year ago
Edited 1 year ago

You can only set ProcessReceipt once. So just combine it into one script.

local marketPlaceService = game:GetService("MarketplaceService")

marketPlaceService.ProcessReceipt = function(receiptInfo)
    local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)

    local function addStage(amount)
        player.leaderstats:FindFirstChild("???? Stage").Value += amount
        wait(1)
        player:LoadCharacter()
    end

    if receiptInfo.ProductId == 1337983530 then
        addStage(1)
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 1339759965 then
        addStage(5)
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end
Ad

Answer this question