Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Donation board saying the player donated 5 robux but there isn't a 5 robux donation in the board?

Asked by 3 years ago

On spawn, most of the time, the donation board thinks that the player donated 5 robux even though there is no "5 Robux" donation button and the player didn't donate anything? What? What is happening here? Also sometimes the leaderboard would say the player didn't donate anything if didn't donate but when it updates it says the player donated 5 robux, but anyways here are the scripts:

The leaderstats (or hiddenstats) script: (ServerScriptService)

local DataStoreService = game:GetService("DataStoreService")
local DonationDataStore = DataStoreService:GetDataStore("Donation")

game.Players.PlayerAdded:Connect(function(player)
    local hiddenstats = Instance.new("Folder") 
    hiddenstats.Name = "hiddenstats" 
    hiddenstats.Parent = player

    local Donation = Instance.new("IntValue", hiddenstats)
    Donation.Name = "Donation"
    Donation.Value = DonationDataStore:GetAsync(player.UserId) or 0

end)

game.Players.PlayerRemoving:Connect(function(Player)
    DonationDataStore:SetAsync(Player.UserId, Player.hiddenstats.Donation.Value)
end)

The donation board script: (StarterGui)

local lbData = game:GetService("DataStoreService"):GetOrderedDataStore("Board")

function AddCommas(num)
    return tostring(math.floor(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
end

function Update()
    local frames = script.Parent.ScrollingFrame:GetChildren()
    for v,v in pairs(frames) do
        if v:IsA("Frame") then
            v:Destroy()
        end
    end
    for _,plr in next, game:GetService("Players"):GetPlayers() do
        pcall(function()
            lbData:UpdateAsync(plr.UserId, function() return plr:FindFirstChild("hiddenstats"):WaitForChild("Donation").Value end) 
        end)
    end

    local data = lbData:GetSortedAsync(false,10)
    local page = data:GetCurrentPage()

    for rank, info in next, page do
        local frame = script.Parent.Sample:Clone()
        frame.Visible = true
        local plrName = game:GetService("Players"):GetNameFromUserIdAsync(info.key)     
        frame:WaitForChild("Place").Text = "#"..rank
        if rank == 1 then
            print("gold")
            frame.BackgroundColor3 = Color3.new(0.941176, 0.737255, 0)
        elseif rank == 2 then
            print("silver")
            frame.BackgroundColor3 = Color3.new(0.784314, 0.784314, 0.784314)
        elseif rank == 3 then
            print("bronze")
            frame.BackgroundColor3 = Color3.new(0.764706, 0.560784, 0.313725)
        else
            print("white")
            frame.BackgroundColor3 = Color3.new(1, 1, 1)
        end
        frame.Username.Text = plrName
        frame.Amount.Text = AddCommas(info.value)
        frame.Visible = true
        frame.Parent = script.Parent.ScrollingFrame
    end
end

while true do
    Update()
    wait(15)
end

The robux button script: (10 robux button as an example) (LocalScript) (StarterGui)

local TService = game:GetService("TweenService")
local Part = script.Parent
local TInfo = TweenInfo.new(
    2,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.InOut,
    math.huge,
    true,
    0
)
local ButtonInfo = {
    ImageColor3 = Color3.fromRGB(99, 122, 255) 
}
local Tween = TService:Create(Part, TInfo, ButtonInfo)

Tween:Play()

local Player = game.Players.LocalPlayer
local MarketPlaceService = game:GetService("MarketplaceService")
local PurchaseButton = script.Parent.Parent

PurchaseButton.MouseButton1Click:Connect(function()
    MarketPlaceService:PromptProductPurchase(Player, 1193184814)
end)

Process Receipt script: (ServerScriptService)

local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")

local productFunctions = {}

productFunctions[1193184814] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 10
        return true
    end

end

productFunctions[1193184916] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 25
        return true
    end

end

productFunctions[1193185042] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 50
        return true
    end

end

productFunctions[1193185371] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 100
        return true
    end

end

productFunctions[1193185511] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 200
        return true
    end

end

productFunctions[1193185552] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 500
        return true
    end

end

productFunctions[1193185580] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 1000
        return true
    end

end

productFunctions[1193185622] = function(receipt, player)
    local stats = player:FindFirstChild("hiddenstats")
    local donation = stats and stats:FindFirstChild("Donation")
    if donation then
        donation.Value = donation.Value + 2000
        return true
    end

end

local function processReceipt(receiptInfo)

    local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
    local purchased = false
    local success, errorMessage = pcall(function()
        purchased = purchaseHistoryStore:GetAsync(playerProductKey)
    end)

    if success and purchased then
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif not success then
        error("Data store error:" .. errorMessage)
    end

    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local handler = productFunctions[receiptInfo.ProductId]

    local success, result = pcall(handler, receiptInfo, player)
    if not success or not result then
        warn("Error occurred while processing a product purchase")
        print("\nProductId:", receiptInfo.ProductId)
        print("\nPlayer:", player)
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local success, errorMessage = pcall(function()
        purchaseHistoryStore:SetAsync(playerProductKey, true)
    end)
    if not success then
        error("Cannot save purchase data: " .. errorMessage)
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end


MarketplaceService.ProcessReceipt = processReceipt

For anyone thinking that there is some code that adds 5 donation points, I tried my hardest to find it and there are NO signs of it.

Answer this question