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

Developer Products not adding to value, Why is this?

Here's my code:

local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local pid1 = 427571385
local pid2 = 427132153
local pid3 = 427572442
local pid4 = 427573555
local pid5 = 427131963
local pid6 = 427132153
local pid7 = 427132281
local pid8 = 427132336

MarketplaceService.ProcessReceipt = function(receiptInfo) 
	for i, player in ipairs(game.Players:GetPlayers()) do
		local Rubys = player.Rubys
		local Coins = player.Coins
		if player.userId == receiptInfo.PlayerId then
				
			elseif receiptInfo.ProductId == pid1 then
				Rubys.Value = Rubys.Value + 100
				
			elseif receiptInfo.ProductId == pid2 then
				Rubys.Value = Rubys.Value + 300
					
			elseif receiptInfo.ProductId == pid3 then
				Rubys.Value = Rubys.Value + 750
					
			elseif receiptInfo.ProductId == pid4 then
				Rubys.Value = Rubys.Value + 1250
		
		-----------  	C O I N S 	---------
				
			elseif receiptInfo.ProductId == pid5 then
				Coins.Value = Coins.Value + 1000	
				
			elseif receiptInfo.ProductId == pid6 then
				Coins.Value = Coins.Value + 2800
				
			elseif receiptInfo.ProductId == pid7 then
				Coins.Value = Coins.Value + 7500
				
			elseif receiptInfo.ProductId == pid8 then
				Coins.Value = Coins.Value + 13500					
				end
			end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

If you're able to find the problem please give me a detailed explanation on where I would add to the script to make it work.

1 answer

Hello eizaray1234! I fixed your Script make sure to inserted in ServerScriptService:

MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()
local pid1 = 427571385
local pid2 = 427132153
local pid3 = 427572442
local pid4 = 427573555
local pid5 = 427131963
local pid6 = 427132153
local pid7 = 427132281
local pid8 = 427132336

local done = 0

for i=1,#players do
    if players[i].userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == pid1 and done == 0 then
            done = 1
            players[i].leaderstats.Rubys.Value = players[i].leaderstats.Rubys.Value + 100
            done = 0
            else
            if receiptInfo.ProductId == pid2 and done == 0 then
            done = 1
            players[i].leaderstats.Rubys.Value = players[i].leaderstats.Rubys.Value + 300
            done = 0
            else
            if receiptInfo.ProductId == pid3 and done == 0 then
            done = 1
            players[i].leaderstats.Rubys.Value = players[i].leaderstats.Rubys.Value + 750
            done = 0
            if receiptInfo.ProductId == pid4 and done == 0 then
            done = 1
            players[i].leaderstats.Rubys.Value = players[i].leaderstats.Rubys.Value + 1250
            done = 0
            -----------     C O I N S   ---------
            else
            if receiptInfo.ProductId == pid5 and done == 0 then
            done = 1
            players[i].leaderstats.Coins.Value = players[i].leaderstats.Coins.Value + 1000
            done = 0
            else
            if receiptInfo.ProductId == pid6 and done == 0 then
            done = 1
            players[i].leaderstats.Coins.Value = players[i].leaderstats.Coins.Value + 2800
            done = 0
            else
            if receiptInfo.ProductId == pid7 and done == 0 then
            done = 1
            players[i].leaderstats.Coins.Value = players[i].leaderstats.Coins.Value + 7500
            done = 0
            if receiptInfo.ProductId == pid8 and done == 0 then
            done = 1
            players[i].leaderstats.Coins.Value = players[i].leaderstats.Coins.Value + 13500
            done = 0
        end
    end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end end end end end end end

I hope that helps you. Good luck.

1 comment

0

-1 for not explaining.

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