New Issue! Devproduct Not Working

About 10 minutes ago, all my devproducts were working, I just made some updates, and now none of them work!
I can buy them, but my stage doesnt go up at all!
Here is my script:

local MPS = game:GetService('MarketplaceService')

MPS.ProcessReceipt = function(recieptInfo)
	if recieptInfo.ProductId == 959727180 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 1
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959728287 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 2
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959744665 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 5
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959761604 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = 13
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
   end
end


Help is appreciated!

1 Like

Do you get any errors?

I’m pretty sure you’d have to convert the data to a number before adding it, like this:
local MPS = game:GetService(‘MarketplaceService’)

MPS.ProcessReceipt = function(recieptInfo)
	if recieptInfo.ProductId == 959727180 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = tonumber(Player.leaderstats.Stage.Value) + 1
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959728287 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = tonumber(Player.leaderstats.Stage.Value) + 2
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959744665 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = tonumber(Player.leaderstats.Stage.Value) + 5
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959761604 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = 13
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
   end
end

I could be wrong, but any information on what’s outputted would be useful. :slight_smile:

2 Likes

no… No errors at all…
And I’m using this script to trigger it:

local Players = game:GetService('Players')
local Player = Players.LocalPlayer
local MPS = game:GetService('MarketplaceService')

script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(Player, 959727180)
end)

Heyo! Make sure you spell ‘ReceiptInfo’ correct. I believe that’s the issue.

1 Like

That isn’t the issue. I changed it, but it still doesn’t work…

Make sure to keep the post updated with changes you make. :grin:

1 Like

Try debugging it and post the output here:

local MPS = game:GetService(‘MarketplaceService’)

MPS.ProcessReceipt = function(recieptInfo)
print("processed")
	if recieptInfo.ProductId == 959727180 then
print("product 1")
print("Id: " .. recieptInfo.Playerid)
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
print("Player: " .. Player.Name)
		Player.leaderstats.Stage.Value = tonumber(Player.leaderstats.Stage.Value) + 1
print("Stats: " .. tostring(Player.leaderstats.Stage.Value))
		Player:LoadCharacter()
print("loaded")
		return Enum.ProductPurchaseDecision.PurchaseGranted
   end
end

Sorry about the awful indenting, but you get the idea.

1 Like

Ok, so in the end, I ended up reverting the Game Version, and it works, the script is this:

local MPS = game:GetService('MarketplaceService')

MPS.ProcessReceipt = function(recieptInfo)
	if recieptInfo.ProductId == 959727180 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 1
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959728287 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 2
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959744665 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = Player.leaderstats.Stage.Value + 5
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif recieptInfo.ProductId == 959761604 then
		local Player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		Player.leaderstats.Stage.Value = 13
		Player:LoadCharacter()
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end





1 Like

That’s the same script, no? Unless I’m missing something, the problem lies elsewhere.

Ok, so I found the issue!
It was a donation board I was using, I put it into the game, and it stopped working, took it out, and started working again, how could this cause the issue?

Depends how the donation board works. It was probably already processing a receipt for the donations.

1 Like

If you’re using the donation board by Nitefal, then Polyheximal is right. Sorry for the late response, but I feel like this falls under the relevant information category of bumping old topics since it could help out other devs that are using the same donation board, and that I haven’t seen anybody mention it.

Anyway, the donation board reads, “If you’re already using the function ProcessReceipt then you must add custom code for this board to work, as only one of these functions may be used in a game. You can update the board’s datastore with this line:”

game:GetService("DataStoreService"):GetOrderedDataStore("TopDonators"):IncrementAsync(PlayerId, ProductPrice)

So, simply add this plus the parameters to your dev product handling script and boom, the donation board and your developer products will work again. Example:

	elseif receiptInfo.ProductId == 1004632422 then -- replace with your ID here
		local PlayerId = receiptInfo.PlayerId
		local ProductPrice = 10
 		game:GetService("DataStoreService"):GetOrderedDataStore("TopDonators"):IncrementAsync(PlayerId, ProductPrice)
		return Enum.ProductPurchaseDecision.PurchaseGranted
1 Like

@bobo1004 is somewhat right. The leaderboard for the donation board doesn’t update, which is the only problematic thing about this solution. If anyone knows how to make the leaderboard update, that’d be great!