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.
Yeah. The problem is is that only one script can set the callback. What you would need to do is go into the donation ProcessReciept script, and copy and paste everything inside the callback. Then just add it in the script in this topic.
I have this error on this line (donation board) quite frankly:
local Products = require(script.Parent.Parent.Products).Products
Error: Products is not a valid member of ModuleScript “Workspace.MainModule”
Remove the .Products
inside the require.
Can you try removing the .Products in the require?
Try doing
local function Processed(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
MarketplaceService.ProccessReceipt:Connect(Processed)