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
	end
	
	
	print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId)
	
	
	local sound = Instance.new("Sound", player)
	sound.SoundId = "rbxassetid://254003734"
	sound.PlayOnRemove = true
	sound:Play()
	sound:Destroy()
	
	if receiptInfo.ProductId == skip1 then 
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
		player:LoadCharacter()
	else
		if receiptInfo.ProductId == skip2 then 
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 2
		player:LoadCharacter()	
	end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
	
end

MarketplaceService.ProcessReceipt = processReceipt
MarketplaceService.ProcessReceipt = processReceipt

StarterGui Button Script:

local productId = 972768947

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

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

end)

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
end

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.