local productId = 1082662118 -- Change to the ID of your developer product.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.leaderstats.Stage.Value < 5 then
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
else
script.Parent.Text = "Stage Limit Reached"
script.Parent.TextColor3 = Color3.new(1, 0, 0)
wait(1)
script.Parent.Text = "Skip Stage"
script.Parent.TextColor3 = Color3.new(1, 1, 1)
end
end)
I think the problem is the second line of code, but I do not know what to do about it. Edit: If you need the other script, here it is, it should be fine:
MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()
local currency = "Stage"
local done = 0
for i=1,#players do
if players[i].userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 1082662118 and done == 0 then
done = 1
players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
players[i].Character.Humanoid.Health = 0
done = 0
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

12 comments
Is this a local script?
Is script.Parent a textbutton? Does it prompt the purchase UI? Are you handling the purchase on the server? Where is the script for handling the purchase?
iOwn_You, yes, the parent is a textbutton.
Also, the other script is completely fine, my real problem is with the limit. I need to make sure that if the player finishes the game that they can't skip the stage again, because if they do, they go back to the start of the game
And for the rest of my questions?
also yes, it is indeed a local script
What is the issue with the skipping exactly?
the issue is that the player shouldn't be able to skip stage when they are at the end of the obby. I wanted to make a stage limit where the text button says: "You beat the game, you cannot skip stage again"
The skip stage button works, and when i buy it it lets me skip the stage. My problem is that it keeps letting me do it, even when I have completed the obby. This means that I can spend infinite amounts of robux at the last stage.RareUsernameO_O -6 — 4m
try player:WaitForChild("leaderstats").Stage.Value
that doesnt seem to work
You got better at asking questions, nice