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

Theres this bug with my product recipt?

game.MarketplaceService.ProcessReceipt = function(reciptInfo)
    local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
    if reciptInfo.ProductId == 1166140314 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50
    elseif reciptInfo.ProductId == 1166140360 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100
    elseif reciptInfo.ProductId == 1166140438 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250
    elseif reciptInfo.ProductId == 1166140622 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500
    elseif reciptInfo.ProductId == 1166140682 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000
    end
end

for some reason, when i buy something, for example the first one, it adds 50 tokens. But when i buy it again, it adds 100 tokens. and when i buy it for the third time, it add 150 tokens this time. It seems like it's adding 50 to every thing. how do i fix this?

2 answers

✓ Accepted answer
game.MarketplaceService.ProcessReceipt = function(reciptInfo)
	local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
	if reciptInfo.ProductId == 1166140314 then
		plr.leaderstats.Tokens.Value += 50
		return -- would it fix if you put a return after every purchase? or try PromptProductPurchaseFinished cos pro :)
	elseif reciptInfo.ProductId == 1166140360 then
		plr.leaderstats.Tokens.Value += 100
	elseif reciptInfo.ProductId == 1166140438 then
		plr.leaderstats.Tokens.Value += 250
	elseif reciptInfo.ProductId == 1166140622 then
		plr.leaderstats.Tokens.Value += 500
	elseif reciptInfo.ProductId == 1166140682 then
		plr.leaderstats.Tokens.Value += 1000
	end
end

4 comments

0

Ok I will try!

0

Uh sorry, that didn't work. But do you have any idea how to use productpurchasefinished?

0

Oh wait, PromptProductPurchaseFinished wouldn't help because it could be like when the player closes the thing.

0

uh you could do like if canceled then return end

Thanks! I used return but modified it a bit for it to work! Here's the finalized code.

game.MarketplaceService.ProcessReceipt = function(reciptInfo)
	local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
	if reciptInfo.ProductId == 1166140314 then
		plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif reciptInfo.ProductId == 1166140360 then
		plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif reciptInfo.ProductId == 1166140438 then
		plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif reciptInfo.ProductId == 1166140622 then
		plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif reciptInfo.ProductId == 1166140682 then
		plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

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