also first post on devforum
-
I need a normal donation board that doesn’t double amounts
-
Some donations are doubled randomly.
-
I have not tried any solutions. I went over all the code multiple times, but I didn’t find any problems.
Once a player buys a product that’s a donation, their donation value increases by the price of what they buy. So if they buy a donation that’s 100 robux, their donation value will increase by 100. However, this seems to double for certain sales. I haven’t experimented to see why this happens. I tested the donation board once, and it seemed to work without any problems, but I don’t remember if I only bought one product or more. I’ve had an instance where someone donated 70, which would be 50 + 10 + 10, but it showed up as 140. Another instance was when someone donated 1500, but it showed up as 2000, instead of doubling to 3000. Back to the main topic, there’s a datastore for how much you donate. This is saved to every 45 seconds with your donation value, and also when you leave. This is used in the top donators board. There’s also a local script which sets the events for the donate products being clicked. This event fires for every button that’s clicked. The donation boards are in the workspace. help please
the first script is the donation board script
server script
local ds = game:GetService("DataStoreService")
local donations = ds:GetOrderedDataStore("Donation1")
while true do
local t = donations:GetSortedAsync(false, 50, 1, 10^50)
local top = t:GetCurrentPage()
for _, v in pairs(script.Parent.SurfaceGui.ScrollingFrame:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
local data = {}
for i, v in ipairs(top) do
local userid = v.key
local amount = v.value
local username = "[Failed To Load]"
pcall(function()
username = game.Players:GetNameFromUserIdAsync(userid)
end)
table.insert(data, {username; amount})
end
for num, d in pairs(data) do
local name = d[1]
local amount = d[2]
local color = Color3.fromRGB(111, 111, 111)
if num == 1 then
color = Color3.fromRGB(0, 232, 213)
elseif num == 2 then
color = Color3.fromRGB(255, 255, 0)
elseif num == 3 then
color = Color3.fromRGB(200, 200, 200)
end
local f = script.Parent.replicated.Frame:Clone()
f.Parent = script.Parent.SurfaceGui.ScrollingFrame
f.Player.BackgroundColor3 = color
f.Amount.BackgroundColor3 = color
f.Player.Text = name
f.Amount.Text = amount .. " R$"
end
wait(60)
end
second script is the donate board script
also i was asked to delete out the product ids
server script
local otherproducts = {
deletedforreasons; -- price: 10
deletedforreasons; -- price: 24
deletedforreasons; -- price: 50
deletedforreasons; -- price: 100
deletedforreasons; -- price: 250
deletedforreasons; -- price: 500
deletedforreasons; -- price: 1000
deletedforreasons; -- price: 5000
}
local market = game:GetService("MarketplaceService")
for _, v in pairs(otherproducts) do
local info = market:GetProductInfo(v, Enum.InfoType.Product)
local price = info.PriceInRobux
local clone = script.Parent.replicated.Frame:Clone()
clone.Parent = script.Parent.SurfaceGui.ScrollingFrame
clone.Button.Text = tostring(price) .. " R$"
end
third script is the script that saves the val
server script
local ds = game:GetService("DataStoreService")
local donationstore = ds:GetOrderedDataStore("Donation1")
local market = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
while true do
wait(45)
donationstore:SetAsync(player.UserId, player.Donation.Value)
end
end)
fourth script controls the local stuff
local script
wait(3)
local otherproducts = {
deletedforreasons; -- price: 10
deletedforreasons; -- price: 24
deletedforreasons; -- price: 50
deletedforreasons; -- price: 100
deletedforreasons; -- price: 250
deletedforreasons; -- price: 500
deletedforreasons; -- price: 1000
deletedforreasons; -- price: 5000
}
local market = game:GetService("MarketplaceService")
for _, v in pairs(workspace.Lobby["Main Area"]["Donation Board"].Donate.board.SurfaceGui.ScrollingFrame:GetChildren()) do
if v:IsA("Frame") then
v.Button.MouseButton1Click:Connect(function()
local price = string.split(v.Button.Text, " R$")[1]
for _, v in pairs(otherproducts) do
local price2 = market:GetProductInfo(v, Enum.InfoType.Product).PriceInRobux
if tonumber(price) == tonumber(price2) then
market:PromptProductPurchase(game.Players.LocalPlayer, tonumber(v))
end
end
end)
end
end
help