I’m trying to have a donation board in the new game I am making. I am not a scripter so I know very little to nothing about scripting, I had to watch a youtube tutorial for this script. If anyone can help me fix this error that would be awesome! The buttons on my donation board are also not working but I am guessing it has something to do with the error message
Output messages:
Script:
local donateAmounts = {"10", "50", "100", "1000", "5000", "50000", "100000"}
local ids = {1252536320, 1252544596, 1252544641, 1252544712, 1252544777, 1252544840, 1252544903}
local mps = game:GetService("MarketplaceService")
local dss = game:GetService("DataStoreService")
local ods = dss:GetOrderedDataStore("Donators")
for i, amount in pairs(donateAmounts) do
local donateButton = script:WaitForChild("DonateButton"):Clone()
donateButton.Text = amount .. " Robux"
donateButton.Parent = script.Parent.DonatePart.DonateGui.DonateList
end
game.ReplicatedStorage.DonateRE.OnServerEvent:Connect(function(plr, button)
local amount = string.gsub(button.Text, " Robux", "")
local id = ids[table.find(donateAmounts, tonumber(amount))]
mps:PromptProductPurchase(plr, id)
end)
mps.ProcessReceipt = function(purchaseInfo)
local amount = mps:GetProductInfo(purchaseInfo.ProductId, Enum.InfoType.Product).PriceInRobux
local success, err = pcall(function()
local totalDonated = ods:GetAsync(purchaseInfo.PlayerId) or 0
ods:SetAsync(purchaseInfo.PlayerId, totalDonated + amount)
end)
return success and Enum.ProductPurchaseDecision.PurchaseGranted or Enum.ProductPurchaseDecision.NotProcessedYet
end
while wait(5) do
for i, child in pairs(script.Parent.LeaderboardPart.LeaderboardGui.LeaderboardList:GetChildren()) do
if child:IsA("Frame") then child:Destroy() end
end
local pages = ods:GetSortedAsync(false, 100)
local top = pages:GetCurrentPage()
for rank, data in ipairs(top) do
local username = game.Players:GetNameFromUserIdAsync(data.key)
local donated = data.value
local leaderboardFrame = script.LeaderboardFrame:Clone()
leaderboardFrame.Rank.Text = "#" .. rank
leaderboardFrame.Username.Text = username
leaderboardFrame.Amount.Text = donated
leaderboardFrame.Parent = script.Parent.LeaderboardPart.LeaderboardGui.LeaderboardList
end
end
