I am currently working on an Obby and wanted a Donationboard and a skip stages button but both separately has not worked because of the processreceipt therefore I have both processreceipt scripts programmed into one and now it works BUT there is an annoying nasty bug, there is yes in the script +1 which means that you go 1 stage further but after the 2nd stage you go 2 stages further and after the 3rd stage 3 stages further. And I just do not understand why. And that’s why I need help!
local Products = require(script.Parent.Parent.workspace.Boards.Products)
local Enabled = true
function GetData()
local Datastore = game:GetService("DataStoreService"):GetDataStore("BoardData")
local Data = Datastore:GetAsync("Data")
if Data == nil then
Data = {ListSize = 15, Datastore = 1, Refresh = 1, Version = 2}
end
local TD = "TopDonators"
if Data.Datastore ~= 1 then
TD = "TopDonators"..Data.Datastore
end
return TD
end
function ReceiptHandler()
warn("Donation Board: ProcessReceipt Activated")
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if receiptInfo.ProductId == 1205369919 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
local numbar = plr.leaderstats.Stage.Value
local stagee = game.Workspace.Stages:WaitForChild(numbar)
plr.Character:SetPrimaryPartCFrame(CFrame.new(stagee.Position))
wait(1)
plr.Character.Humanoid.Health = 0
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
local numberBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(playerProductKey, 1)
local ProductBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistoryCount"):IncrementAsync(receiptInfo.ProductId, 1)
local PlayerFound = false
for i, v in pairs (game.Players:GetChildren()) do
if v:IsA('Player') then
if v.userId == receiptInfo.PlayerId then
for _, p in pairs (Products.Products) do
if p.ProductId == receiptInfo.ProductId then
if v ~= nil then
PlayerFound = true
game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
end
end
end
end
end
end
if PlayerFound ~= true then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
if Products.AbortCustomPurchases then
if Products.AbortCustomPurchases == true then
Enabled = false
warn("Donation Board: Custom ProcessReceipt Enabled!")
else
ReceiptHandler()
end
else
ReceiptHandler()
end