My Skip Stage Script wont work [Fixed]

What I want to get are two skipstage one of skipstage 1 and another of skipstage2

First when i have skipstage 1 it works but when i add else if and copy and paste it doesn’t work anyone know what’s wrong? and to add I did not get any error in the output

script(server script service) :

local skip1 = 972768947
local skip2 = 972768973 

local MarketplaceService = game:GetService("MarketplaceService")

local function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId)
	local sound ="Sound", player)
	sound.SoundId = "rbxassetid://254003734"
	sound.PlayOnRemove = true
	if receiptInfo.ProductId == skip1 then 
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
		if receiptInfo.ProductId == skip2 then 
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 2
	return Enum.ProductPurchaseDecision.PurchaseGranted

MarketplaceService.ProcessReceipt = processReceipt
MarketplaceService.ProcessReceipt = processReceipt

StarterGui Button Script:

local productId = 972768947

local player = game.Players.LocalPlayer


game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)


Please use Preformatted text (Ctrl+Shift+C) to show us your source code because it’s going to be easier for us to read your code and so that we can help you. Thank you :slight_smile:
Here is the icon on how the feature button looks like: image

Ok Done :smile: :smile: :smile:

This could just be a result of you getting confused with the if statements. You have a separate if statement in the else condition rather than an elseif clause. If you ever intend to add more products, then you’ll end up with a longer chain of ifs as well.

if receiptInfo.ProductId == skip1 then
    -- Skip 1 code
elseif receiptInfo.ProductId == skip2 then
    -- Skip 2 code

You also, er, have a double ProcessReceipt assignment at the bottom. Is that a mistake?

1 Like

Oh wow thanks so much :grinning: and yes the double ProcessReceipt assignment was a mistake

Hi again, sometimes it works and sometimes it doesn’t its like the script doesn’t load some times :confused: and no error in the output

It’d be helpful to provide more information about the circumstances, such as the current script you’re working with. I can’t exactly help you when all I know is “it doesn’t work”. Try also doing some debugging to see if you can pinpoint where exactly it doesn’t work by adding print statements and checking which ones run and which ones don’t.