How Do I make this Skip Stage Script?

As the title suggest, I want to achieve a Skip Stage Script, but the script I have made is totally not working, would love some help thank you.

MarketplaceService = game:GetService("MarketplaceService")

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

local currency = "Stage"

local done = 0

for i=1,#players do
    if players[i].userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == 959773024 and done == 0 then --That Number is the devProduct ID
            done = 1
            players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
            players[i].Character.Humanoid.Health = 0
            done = 0
        end
    end
end
return Enum.ProductPurchaseDecision.PurchaseGranted    
end```
2 Likes

What exactly isn’t working? Was there any errors?

No there was no syntax highlighted, this script isn’t working.

The purchase is prompted when I click my gui which has a seprate script but when I buy it, my stage doesn’t change.

Well first off your way of getting ID is quite interesting…

A easier way of getting the player is something like

MPS.ProcessReceipt = function(receiptInfo)
receiptInfo.ProductId == 000000000 then 
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		

I think part of your problem could be that. You seem to be over complicating it

2 Likes

This is the correct way of doing it.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local StageProductId = 959773024

MarketplaceService.ProcessReceipt = function(receiptInfo)
	local PlayerId = receiptInfo.PlayerId
	local Player = Players:GetPlayerByUserId(PlayerId)
	local ProductId = receiptInfo.ProductId
	
	local StatFolder = Player:FindFirstChild("leaderstats")
	local StageValue = StatFolder and StatFolder:FindFirstChild("Stage")
	
	if StageValue then
		if ProductId == StageProductId then
			StageValue.Value = StageValue.Value + 1
			Player:LoadCharacter()
			return Enum.ProductPurchaseDecision.PurchaseGranted  
		end
	end
	return Enum.ProductPurchaseDecision.NotProcessedYet  
end
4 Likes

Hm… didn’t work.

Just tested it in studio.

Ah, yeah I missed .Value, I have updated the code above.

1 Like

But it still did not work.

30 char…

Do you know if there were any errors?

1 Like

No, the code had absoultely no errors but, my stage value didn’t go up.

Are you sure its the right ID?

Yes, it is.

30 char…

Is it getting past the If statements?

Oh it worked!

I removed the Load Character and replaced it with Humanoid Health and it worked, all credit goes to @Proxus

3 Likes

Glad you got it to work, but LoadCharacter is far better as it instantly loads the player’s character, rather than having to wait for it to respawn.

3 Likes

But there is one problem, tested it just now it worked, and I made no edits no nothing and the next time I tested, it didn’t work. Is this a Roblox Issue?

1 Like