Skip stage doesn't work

Hello developers, i’ve been trying to make a skip stage button for some time now but every time i try different scripts it just doesn’t work, here’s the problem:

Sometimes the script actually works and actually teleports me to the next stage, but sometimes it just doesn’t straight up work, this is my script:

local martketplace = game:GetService("MarketplaceService")

martketplace.ProcessReceipt = function(receiptInfo)
	local players = game.Players:GetPlayers()
	local finish = 0
	for i=1, #players do
		if players[i].UserId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == 3294504288 and finish == 0 then -- change your product id here at 0000000
				finish = 1 
				players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
				players[i]:LoadCharacter()
			end
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
1 Like

When it doesn’t work, does it error? If yes provide the error

If 3294504288 is the ID for the skip stage developer product then it seems like it will work once because the variable Finish is set to 1 and not 0 back again.

how didn’t i notice this :man_facepalming:
char limitt

it’s hard to explain, sometimes when i play test it doesn’t work and if i play test again it might work, there’s like a 25% chance lol

Try this loop over the C style one

for _, plr in game.Players:GetPlayers() do
    if receipt.UserId == plr.UserId do
        -- next stage stuff, instead of players[i] just use plr or whatever you names the second variable in the loop
        break -- so the loop ends, no need for extra variable
    end
end

so like this?

local martketplace = game:GetService("MarketplaceService")

martketplace.ProcessReceipt = function(receiptInfo)
	for _, plr in game.Players:GetPlayers() do
		if receiptInfo.UserId == plr.UserId then
			if receiptInfo.ProductId == 3294504288 then
				plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
				plr:LoadCharacter()
				break
			end
		end
	end
end

Yes, you should make it “and productId ==…” Instead of extra if
char limit char limit char limit char limit

Why don’t you just GetPlayerByUserId instead of looping? one of the use cases in its description on the documentation is to use with ProcessReceipt…

1 Like

Never heard of this, very useful.

so something like this

local martketplace = game:GetService("MarketplaceService")

martketplace.ProcessReceipt = function(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if receiptInfo.ProductId == 3294504288 then
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
		player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Yeah something like that (I hate the minimum character requirement)

unfortunately it still has the same results has the other ones

Does it atleast set the stage to +1 and just not teleport, or does it not do anything at all?

doesn’t do anything at all (i know your pain of the minimum character requirement)

Could you add some prints and show what it prints when it doesn’t work?
like this:

local martketplace = game:GetService("MarketplaceService")

martketplace.ProcessReceipt = function(receiptInfo)
 	print("A")
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	print("B")
	if receiptInfo.ProductId == 3294504288 then
		print("C")
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
		player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Maybe it has to do something with Studio? Try it in the roblox player, im sure studio is messy when it comes to paid stuff

doesn’t print anything, it’s really strange, whiplash3r theory might be true

doesn’t work there neither, it’s really strange

Are you sure you only have one ProcessReceipt? Search for “ProcessReceipt” using Ctrl+Shift+F