I’m trying to make an obby game, and I’m watching a tutorial on how to make a “Skip Stage Button” but when I test it out, I get a pop up that says it did not work, I have tried looking over my code and trying to buy the developer product again, but it does not work.
Pop up:
Script:
local skipId = 20548954
local mps = game:GetService("MarketplaceService")
local maxStage = #game.Workspace.Checkpoints:GetChildren()
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.leaderstats.Stage.Value < maxStage then
mps:PromptProductPurchase(game.Players.LocalPlayer,skipId)
end
end)
Part where he is scripting it:
Plz tell me what I need to add or remove, because I don’t see where I went wrong.
I am pretty sure that that number is not a developer product. If you paste in the id to roblox, it is a game pass. I made a game last year with some dev products and the ids were at least 1156115633, so your number of 20548954 is way too small. If you look up your id, you get it for a game http://www.roblox.com/Survive-The-321-Disasters-place?id=62507809, created 11 years ago, and the dev product is off sale. Creator Dashboard (roblox.com)
I think that the ID that you are testing is invalid.
So it works now, but it won’t let me go to the next stage
Code:
local skipId = 1379180803
local mps = game:GetService(MarketplaceService)
mps.ProcessReceipt = function(info)
local plrId = info.PlayerId
local productId = info.ProductId
local plr = game.Players:GetPlayerByUserId(plrId)
if productId == skipId then
plr.leaderstats.Stage.Value = 1
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local skipId = 1379180803
local mps = game:GetService(MarketplaceService)
mps.ProcessReceipt = function(info)
local plrId = info.PlayerId
local productId = info.ProductId
local plr = game.Players:GetPlayerByUserId(plrId)
if productId == skipId then
plr.leaderstats.Stage.Value = 1
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
That’s just increasing their stage value but you have to actually teleport the player there.
Since you have the player in your plr variable, to get the character would be as easy as
local char = plr.Character or plr.CharacterAdded:Wait()
then you just want to teleport the character to the checkpoint of the next stage.
That would look something like this: char.Position = checkpoint.Position + Vector3.new(0,3,0)
The get the checkpoint, assuming you have them all named Checkpoint1 (replace 1 with the stage number), it should be a matter of local checkpoint = game.Workspace:FindFirstChild('Checkpoint'..(plr.leaderstats.Stage.Value))
Also just noticed you changed their stage to stage 1 instead of adding.
Your script, depending on your workspace, should be something like this:
local skipId = 1379180803
local mps = game:GetService(MarketplaceService)
mps.ProcessReceipt = function(info)
local plrId = info.PlayerId
local productId = info.ProductId
local plr = game.Players:GetPlayerByUserId(plrId)
local char = plr.Character or plr.CharacterAdded:Wait()
if productId == skipId then
plr.leaderstats.Stage.Value += 1
local checkpoint = game.Workspace:FindFirstChild('Checkpoint'..(plr.leaderstats.Stage.Value)
char.Position = checkpoint.Position + Vector3.new(0,3,0)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Hello, sorry for the late response. I just tried this script and it did not work, I could buy the developer product, just would not let me skip the stage