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

How do I add a developer product that would give points to a player to my game?

Here's my code so far -

ShekelsGiven = 100

ProductID = 31831485

game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
	
	for i, player in ipairs(game.Players:GetChildren()) do
		
		if player.userId == receiptInfo.PlayerId then
		
			if receiptInfo.ProductId == ProductID then
				
				if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then
					
					player.ShopValues.Shekels.Value = player.ShopValues.Shekels.Value + ShekelsGiven
				
				end
			
			end
		
		end
		
	end
	
	return Enum.ProductPurchaseDecision.PurchaseGranted

end

Thanks for reading.

1 comment

1 answer

You would do this:

local ShekelsGiven = 100
game:GetService("MarketplaceService").ProcessReceipt = function (receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do

		if player.userId == receiptInfo.PlayerId then
 
 
			-- check which product was purchased
			if receiptInfo.ProductId == productId then

if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then
           player. leaderstats.Shekels.Value = player. Leaderstats.Shekels.Value + ShekelsGiven
 
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end)

Change Shekels in leaderstats to whatever you have as the leaderstats value for storing the points. Place this code in a Server Script as only the server can process receipts.

1 comment

0

hm, it doesn't work for some reason. I'll edit with what I have now.

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