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

How do i make developer product that increases money OR health?

Yea can some one plz teach me how to do it?...

1 answer

✓ Accepted answer
local MarketplaceService = game:GetService("MarketplaceService")
local Money = YOURID

local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
 
MarketplaceService.ProcessReceipt = function(receiptInfo) 
	local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
	if PurchaseHistory:GetAsync(playerProductKey) then
		return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it.
	end
	-- find the player based on the PlayerId in receiptInfo
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then -- Seems like we can't find the player... already left?
		return Enum.ProductPurchaseDecision.NotProcessedYet -- Can't process
	end
	if receiptInfo.ProductId == Money then
		-- handle purchase. In this case we are healing the player.
		player.Data.SafeGold.Value = player.Data.SafeGold.Value + 0
		player.Data.Gold.Value = player.Data.Gold.Value + 0
	end
-- record the transaction in a Data Store
PurchaseHistory:SetAsync(playerProductKey, true)
-- tell ROBLOX that we have successfully handled the transaction (required)
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

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