Hi there! I have a question, I am currently working on a donation board for my Difficulty Chart Obby, now, the problem is that the script simply does not work ingame, but it does in Studio. The skip stage part works, but if someone donated, the amount doesn’t get added to the board his datastore.
Script:
local SkipId = 1137658844
local Players = game:GetService("Players")
local Products = require(game.Workspace.Boards.Products)
local function processReceipt(receiptInfo)
local plr = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not plr then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == SkipId then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
plr.TeleportedStage.Value = plr.TeleportedStage.Value + 1
wait(.1)
plr:LoadCharacter()
return Enum.ProductPurchaseDecision.PurchaseGranted
else
local function GetData()
local Datastore = game:GetService("DataStoreService"):GetDataStore("BoardData")
local Data = Datastore:GetAsync("Data")
if Data == nil then
Data = {ListSize = 30, Datastore = 1, Refresh = 1, Version = 2}
end
local TD = "TopDonators"
if Data.Datastore ~= 1 then
TD = "TopDonators"..Data.Datastore
end
return TD
end
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
wait(2)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
--Set Callback
local mps = game:GetService("MarketplaceService")
mps.ProcessReceipt = processReceipt