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

Skip Stage script works with one button, but not another?

Asked by 7 years ago

I have an obby, and there is a skip stage button. There is a skip 10 stages, and skip 1. The skip 1 works fine, but skip 10 is broken. Here is the local script in it:

local productId = 53038472
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)

Here is the other script that isnt local:

MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
players = game.Players:GetPlayers()

currency = "Stage"

done = 0

for i=1,#players do
    if players[i].userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == 53038472 and done == 0 then
            done = 1
            players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 10
            players[i].Character.Humanoid.Health = 0
            done = 0
        end
    end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end


these seem so perfect, whats wrong?

0
You see where it says "players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 10"? Thats what the stage is supposed to go up buy when the dev product is bought 0HappyManDudeguy0 15 — 7y

2 answers

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

Check your output and see what ends up printing.

local MarketplaceService = game:GetService("MarketplaceService")
local currency = "Stage"
MarketplaceService.ProcessReceipt = function(receiptInfo)
    local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
        return Enum.ProductPurchaseDecision.NotProcessedYet 
    end
    if receiptInfo.ProductId == 53038472 then 
        print("Correct receipt")
        local leaderstats = player:findFirstChild("leaderstats")
        if leaderstats then 
            print("Found leaderstats")
            local currency = leaderstats:findFirstChild(currency)
            if currency then 
                print("Found currency")
                currency.Value = currency.Value + 10
                player:LoadCharacter()
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted 
end
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

it's easy to make skip stage script working i made video this helpful

click here

watch the video and do it and iam sure this will work with you

Answer this question