local MarketplaceService = game:GetService("MarketplaceService")
print("1")
MarketplaceService.ProcessReceipt = function(receiptInfo)
print("2")
local players = game.Players:GetPlayers()
local done = 0
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 1086221671 and done == 0 then
done = 1
players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
players[i]:LoadCharacter()
done = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
That doesn’t work because MarketplaceService.ProcessReceipt is a callback, and you must set it as a function, not create a connection. In order to make this callback run, you must prompt the user to purchase something, whether it be a gamepass or dev product.
local player = game.Players.LocalPlayer
local productId = 1086221671
script.Parent.MouseButton1Click:Connect(function()
print("Button_Pressed")
script.Parent.SkipStageScript.Click:Play()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
local MarketplaceService = game:GetService("MarketplaceService")
print("1")
MarketplaceService.ProcessReceipt = function(receiptInfo)
print("2")
local players = game.Players:GetPlayers()
local done = 0
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 1086221671 and done == 0 then
done = 1
players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
players[i]:LoadCharacter()
done = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end)
local player = game.Players.LocalPlayer
local productId = 1086221671
script.Parent.MouseButton1Click:Connect(function()
print("Button_Pressed")
script.Parent.SkipStageScript.Click:Play()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
Basically, the purchase goes through but it won’t work.
I’ve had a very similar issue before. It was a while ago. What I did was I had a donation board that also set the callback. The callback can only be set once. Do you have a donation board or anything else similar?