I’m getting this error in studio, does this not work in studio?:
03:44:29.412 Failed to process receipt: ▼ {
["CurrencySpent"] = 0,
["CurrencyType"] = Robux,
["PlaceIdWherePurchased"] = 12821899295,
["PlayerId"] = 433349,
["ProductId"] = 1504969097,
["PurchaseId"] = "2afda9bf2a9aa4073fc01610138e50bb"
} attempt to call a nil value - Server - PurchaseHandler:37
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
productFunctions[1504961992] = function(receipt, player)
if player.Character and player.Character:FindFirstChild("Humanoid") then
print("Give stars")
player.PlayerData.Stars.Value += 50
-- Indicate a successful purchase
return true
end
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- Get the handler function associated with the developer product ID and attempt to run it
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The player has received their benefits!
-- return PurchaseGranted to confirm the transaction.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
-- the player's benefits couldn't be awarded.
-- return NotProcessedYet to try again next time the player joins.
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt