Skip Stage Developer Product doesn't work

Hello! I have been working on an Obby Game for the past 3 months (not the best option, I know) cause I’m trying to start with small Projects, and later on move to larger Projects.

GOAL & ISSUE

I’m trying to script it so there is a Skip Stage Developer Product. I’ve finished the whole obby (Building, Scripting and UI), and this is the only thing left, and then I’ll make it public.

Well, pretty much I can’t get the Script to work, even tho I’m pretty sure there are no issues with it. I’ve scripted it to make the Developer Product Purchase pop-up thing, but the Developer Product doesn’t really do anything.

SCRIPTS

(WORKS) This is the script for the Checkpoints in ServerScriptService:

local checkpoints = workspace.Checkpoints

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Value = 1
	stage.Parent = leaderstats
	
	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		wait()
		char:MoveTo(checkpoints[stage.Value].Position)
		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == stage.Value +1 then
					stage.Value = stage.Value +1
				end
			end
		end)
	end)
end)

(DOESNT WORK) This is the script for the Developer Product in ServerScriptService:

local marketPlaceService = game:GetService("MarketplaceService")

marketPlaceService.ProcessReceipt = function(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerID)
	
	if receiptInfo.ProductId == 1282206358 then
		player.leaderstats.Stage.Value += 1
		wait(0.5)
		player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

EXTRA INFO

There aren’t any errors in the OutPut so idk if it’s a Roblox Error or it just doesn’t work well. Please tell me if you need more information about the Game or about the Scripts. Well, thanks for reading this, and have a good day!! :happy3:

I’m surprised it never actually errored for you. Just recreated this on my end and it errored on line 4 of the developer product script.

The issue is, in the receiptInfo parameter (which is a dictionary), ‘PlayerID’ isn’t a valid index and therefore is nil and returned an (Argument 1 is missing) error. To fix it, simply changed this to ‘PlayerId’.

Can confirm this worked for me, I hope it does for you too. :slight_smile:

local marketPlaceService = game:GetService("MarketplaceService")

marketPlaceService.ProcessReceipt = function(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	
	if receiptInfo.ProductId == 1282206358 then
		player.leaderstats.Stage.Value += 1
		wait(0.5)
		player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end
1 Like

God…Thank you SO much. I feel so stupid rn. It didn’t say anything on the OutPut at all so I was really confused. Thank you and have a wonderful day!!! :happy3:

1 Like

No problem, wasn’t your fault if it never popped up as an error for you so don’t put yourself down. You have a wonderful day too. :grin:

1 Like