Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Tizzel40 243 Moderation Voter
6 years ago
Edited 6 years ago

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

Closed as Not Constructive by M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 6 years ago
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
Ad