Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

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

2 answers

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.