Hello developers, i’ve been trying to make a skip stage button for some time now but every time i try different scripts it just doesn’t work, here’s the problem:
Sometimes the script actually works and actually teleports me to the next stage, but sometimes it just doesn’t straight up work, this is my script:
local martketplace = game:GetService("MarketplaceService")
martketplace.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()
local finish = 0
for i=1, #players do
if players[i].UserId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 3294504288 and finish == 0 then -- change your product id here at 0000000
finish = 1
players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
players[i]:LoadCharacter()
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
If 3294504288 is the ID for the skip stage developer product then it seems like it will work once because the variable Finish is set to 1 and not 0 back again.
for _, plr in game.Players:GetPlayers() do
if receipt.UserId == plr.UserId do
-- next stage stuff, instead of players[i] just use plr or whatever you names the second variable in the loop
break -- so the loop ends, no need for extra variable
end
end
local martketplace = game:GetService("MarketplaceService")
martketplace.ProcessReceipt = function(receiptInfo)
for _, plr in game.Players:GetPlayers() do
if receiptInfo.UserId == plr.UserId then
if receiptInfo.ProductId == 3294504288 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
plr:LoadCharacter()
break
end
end
end
end
local martketplace = game:GetService("MarketplaceService")
martketplace.ProcessReceipt = function(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == 3294504288 then
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
player:LoadCharacter()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Could you add some prints and show what it prints when it doesn’t work?
like this:
local martketplace = game:GetService("MarketplaceService")
martketplace.ProcessReceipt = function(receiptInfo)
print("A")
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print("B")
if receiptInfo.ProductId == 3294504288 then
print("C")
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
player:LoadCharacter()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end