That is a callback, have you tried prompting the user to purchase an item?
Try remplace:
MarketPlaceService.ProcessReceipt = function(receiptInfo)
by
MarketplaceService.ProcessReceipt:Connect(function(receiptInfo)
Add a “)” at the last “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.
Yes, I have.
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)
So it prints “Button_Pressed” locally as well as “1” on the server at the start, but not “2” inside .ProcessReceipt
?
Yes, you’re correct. It prints “Button Pressed” and “1”. More information here: Skip Stage not working - #23 by WooleyWool
Did the purchase go through, or was there an error with the purchase?
An error, see my post above for more information.
What line is the error coming from?
What is the error? That would help a lot
This is the error:
There are no errors, like I said above I just wanted to know why “2” wasn’t being printed.
I’ve changed the script:
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.
The first script is a server script, correct?
Yup and then of course the other one is parented under the skip button.
You have an extra closing parenthesis on the last line of the first script.
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?
Deleted that, still doesn’t seem to work. It’s a bizarre issue.
Oh that makes sense, because it worked before I had a donation board… Thats strange…
Which donation board are you using? The donation board may be hooking up another ProcessReceipt function.