So i've made a dev product that let's you skip a level for robux and it worked perfectly at first but now if i try to use it a few times in a row it starts skipping at first 2 levels at a time then 3 and so on but i have no clue why it's doing that. It's suppose to add +1 to stage number at the leaderboard and teleport the player to the next checkpoint, also after i die once i can't press the button anymore it doesn't respond with no errors in the output,i'd appreciate any input
Thanks for your time
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 50041340
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productId then
print 'y'
local stats = player:WaitForChild("leaderstats")
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
local stage = game.Workspace:WaitForChild(stats.Stage.Value)
wait(1)
print '2'
player.Character.Humanoid.Torso.CFrame = stage.CFrame + Vector3.new(0,3,0)
print '3'
end
end
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
