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

How to Developer Products?

How could this be more efficient, sometimes it does not give them cash.

local Products={
	["0"]=100, --Hidden
	["0"]=200, --Hidden
	["0"]=300, --Hidden
	["0"]=400, --Hidden
	["0"]=500, --Hidden
}

Game:GetService("MarketplaceService").ProcessReceipt=function(Receipt)
	local PlayerProductKey = Receipt.PlayerId.."_"..Receipt.PurchaseId
	for _,Player in ipairs(Game.Players:GetChildren())do
			for i, v in pairs(Products)do
				if tostring(Receipt.ProductId)==i then
					repeat wait(2) until Player:FindFirstChild("leaderstats")
 					Player:FindFirstChild("leaderstats").CashPLAYER.Value = Player:FindFirstChild("leaderstats").CashPLAYER.Value + v
					Game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(PlayerProductKey, 1)
					return Enum.ProductPurchaseDecision.PurchaseGranted
				end
		end
end
end

1 answer

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