This is a server script however it will only work for +100 money and none of the rest. Do I need to make separate scripts for each dev product?

Script:

local MarketplaceService = game:GetService('MarketplaceService')
local devproductid = 332876152

local devproductid2 = 332876345

local devproductid3 = 332876639

local devproductid4 = 332876838

local devproductid5 = 332876996

local devproductid6 = 332877350

local devproductid7 = 332877532

MarketplaceService.ProcessReceipt = function(receiptInfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == devproductid then
				--100
				player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100
				
					if receiptInfo.ProductId == devproductid2 then
						--500
						player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500			
							
							if receiptInfo.ProductId == devproductid3 then
								--1250
								player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1250
								
									if receiptInfo.ProductId == devproductid4 then
										--2750
										player.leaderstats.Money.Value = player.leaderstats.Money.Value + 2750
										
										if receiptInfo.ProductId == devproductid5 then
											--3500
												player.leaderstats.Money.Value = player.leaderstats.Money.Value + 3500
											
											if receiptInfo.ProductId == devproductid6 then
												--7500
													player.leaderstats.Money.Value = player.leaderstats.Money.Value + 7500
													
												if receiptInfo.ProductId == devproductid7 then
													--2750
														player.leaderstats.Money.Value = player.leaderstats.Money.Value + 10000		
			
															end				
			
													end			
			
											end				
			
									end		
		
							end	
					end	
							
			end	
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

3 comments

0

Also sorry for the weird wrapping the site did

0

The other if statements are inside the first if statement; you should try to use elseif instead of ifs after the 1st if statement.

0

Don't use GetChildren on Players, and it's spelt UserId, not userId