Here is my local script in a TextButton:
script.Parent.MouseButton1Click:Connect(function()
local ms = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
ms:PromptProductPurchase(plr,979885055)
end)
Here is my script in workspace:
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[979885055] = function(receipt, player)
player.Character.HumanoidRootPart.Position = workspace:FindFirstChild(tostring(player.leaderstats.Stage.Value))
return true
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
Here is the error in output:
16:02:22.670 - Error occurred while processing a product purchase
ProductId: 979885055
Player: PrismaticFruits
This is supposed to be a skip stage developer product for my obby. The stage value is in a Folder called leaderstats in the player.
Can someone please tell me what is wrong? Thanks in advance!

3 comments
What line is causing an error?
Sorry it wasn't an error it was a warning that the script generated.
Line 37