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

Skip Stage Button for Obby not working?

I am having an issue with my skip stage button for my obby, basically when the player purchases the gamepass, nothing happens. The person who was helping me with the script, tested it in his game, and it was working. However, in my game, the script does not. Neither my friend, or I have a clue as to what the issue is, because no errors pop up.

Client code:

local marketplaceservice = game:GetService("MarketplaceService")
local skipId = 1110600158

function marketplaceservice.ProcessReceipt(receiptInfo)
	print("hi")
	if receiptInfo.ProductId == skipId then
		local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		local succ,err = pcall(function()
			plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
			plr.CurrentStage.Value = plr.CurrentStage.Value + 1
			plr:LoadCharacter()
		end)
		if err then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		else
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
end

Code in the GUI:

local MarketPlaceService = game:GetService("MarketplaceService")
local Button = script.Parent.ImageButton
local player = game.Players.LocalPlayer
local skipProduct = 1110600158
local skipEvent = game.ReplicatedStorage.Events.SkipStage

Button.MouseButton1Down:Connect(function()
	MarketPlaceService:PromptProductPurchase(game.Players.LocalPlayer,skipProduct)
end)

Any suggestions would be appreciated! (:

7 comments

0

Does the output print "hi"?

0

I would recommend printing something when an error is detected as well, maybe even the error itself as the issue could be silently happening in the pcall.

0

The ouput does not print hi.

0

I actually recommend using a open-sourced obby system which includes skip stage as well. https://devforum.roblox.com/t/techys-obby-system-all-your-obby-needs-in-one-includes-stage-selector/785271/

0

Does the Prompt appears when you click on the gui?

0

Is the skip a Gamepass or a Product?

0

It is a developer product, and the prompt to purchase it does pop up.

1 answer

Firstly, in gamepass purchases, use :PromptGamepassPurchase() because :PromptProductPurchase() doesn't work with gamepasses. Try using this code:

local MarketPlaceService = game:GetService("MarketplaceService")
local Button = script.Parent.ImageButton
local player = game.Players.LocalPlayer
local skipProduct = 1110600158
local skipEvent = game.ReplicatedStorage.Events.SkipStage

Button.MouseButton1Down:Connect(function()
    MarketPlaceService:PromptGamePassPurchase(game.Players.LocalPlayer,skipProduct)
end)

If this doesn't work, comment below. I'll try fix it.

1 comment

0

Unfortunately, this did not work, now instead of prompting the player to purchase the gamepass, it pops up with an error. I will leave the error in a screenshot. https://gyazo.com/7c6fef7daa714bacd5b70332a0591b48

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