local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local purchaseHistoryStore = game:GetService("DataStoreService"):GetDataStore('purchaseHistoryStore')
local productFunctions = {
[1] = function(player)
if player.Character and player.Character:FindFirstChild("Humanoid") then
-- Heal the player to full health
player.Character.Humanoid.Health = 0
-- Indicate a successful purchase
return true --- RIGHT HERE IT RETURNS TRUE BUT I SAW NO POINT IS THERE A POINT IN DOING THIS?
end
end,
}
MarketplaceService.ProcessReceipt = function(ReceiptInformation)
-- Determine if the product was already granted by checking the data store
local playerProductKey = ReceiptInformation.PlayerId .. "_" .. ReceiptInformation.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
-- If purchase was recorded, the product was already granted
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(ReceiptInformation.PlayerId)
if not player then
-- The player probably left the game
-- If they come back, the callback will be called again
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[ReceiptInformation.ProductId]
handler(player)
print('Finished')
return Enum.ProductPurchaseDecision.PurchaseGranted
end
COMMUNITY QUESTION
Whats the point of returning true in a developer product script?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.
