Explanation: So I was trying to make a top donator leaderboard. However, I ended up encountering an error while trying to do so. I was trying to save the info of the donation that a player made into a DataStore so that the leaderboard updates. But when I put the second argument which was supposed to be the value of the DataStore in line 43, it gives me an error saying "Unable to cast Instance to int64". This may be because I got no clue how to write the second argument and so I tried to get the PriceInRobux and make it as a value for the argument by doing:
game:GetService("MarketplaceService"):GetProductInfo(--[[Some Arguments here]]).PriceInRobux
I know I was not supposed to do that. Does anyone have any idea how to write the second argument?
Here's the ServerScript named "DeveloperProductServer" located in ServerScriptService:
local MarketPlaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local RobuxDataStore = DataStoreService:GetOrderedDataStore("RobuxDateStore")
local RobuxDonateEvent = game:GetService("ReplicatedStorage"):WaitForChild("EventsFolder"):WaitForChild("RobuxDonateEvent")
local function UpdateLeaderBoard()
local Success, ErrorMessage = pcall(function()
local Data = RobuxDataStore:GetSortedAsync(false, 15)
local RobuxDSPage = Data:GetCurrentPage()
for RobuxDonated, data in ipairs(RobuxDSPage) do
local Username = game:GetService("Players"):GetNameFromUserIdAsync(tonumber(data.key))
local RobuxAmount = data.value
local IsOnLeaderBoard = false
for i, v in pairs(workspace:WaitForChild("GlobalLeaderboard"):WaitForChild("lbGUI"):WaitForChild("Holder"):GetChildren()) do
if v.Player.Text == Username then
IsOnLeaderBoard = true
break
end
end
if RobuxAmount and IsOnLeaderBoard == false then
local ClonelbFrame = game:GetService("ServerStorage"):WaitForChild("lbFrame"):Clone()
ClonelbFrame.Player.Text = Username
ClonelbFrame.Amount.Text = RobuxAmount
ClonelbFrame.Position = UDim2.new(0, 0, ClonelbFrame.Position.Y.Scale + (0.08 * #workspace:WaitForChild("GlobalLeaderboard"):WaitForChild("lbGUI"):WaitForChild("Holder"):GetChildren()), 0)
ClonelbFrame.Parent = workspace:WaitForChild("GlobalLeaderboard"):WaitForChild("lbGUI"):WaitForChild("Holder")
end
end
end)
if not Success then
error(ErrorMessage)
end
end
local function processReceipt(ReceiptInfo)
local PlayerUserId = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
if not PlayerUserId then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print("Player Donated Robux!")
RobuxDonateEvent:FireClient(PlayerUserId)
while true do
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
RobuxDataStore:SetAsync(game:GetService("Players"):GetNameFromUserIdAsync(PlayerUserId)) -- What Do I Write For The Second Argument??
end
for _, Frame in pairs(workspace:WaitForChild("GlobalLeaderboard"):WaitForChild("lbGUI"):WaitForChild("Holder"):GetChildren()) do
Frame:Destroy()
end
UpdateLeaderBoard()
wait(10)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketPlaceService.ProcessReceipt = processReceipt

19 comments
Oo understood, since im trying to make a top donator leaderboard here, what data can i use?
What data were you planning on storing if you used a DataStore in the first place?
the info of the donation player made
Then store that
how do i write the code?
Can you show me where the donation info is? Your script is unnecessarily complex and it’s a little late so I’m particularly tired, I apologize if I seem a tad bit rude but I’m still here to help with as much as I can
So basically, im trying to make it so that when a player pressed a donate button, it will prompt the purchase and if success, then the leaderboard will get updated if they donated enough robux
Here's how my explorer looks like: https://ibb.co/b5VczvN & https://ibb.co/gTRLMxS
Here's a picture of the donation Frame: https://ibb.co/KxXZtvG
After a load of research, and analysis of your program—of which I take back my previous claim—I finally have what you need! You’ll want to use :IncrementAsync() to handle this operation, as you’re adding to the data. After reading up on ProcessRecipts, I noticed a piece of information that is fundamental to your attempt.
There is a key within the Receipt Table titled CurrencySpent. Since you seem to be loading information into a variable named RobuxAmount, I assume this will protrude to total amount donated, so I thought that using CurrencySpent is what we need.
it works but prints 0 when i try to print the CurrencySpent. nani? I literally "donated" 25 robux (it's a test purchase).
Sorry for the late reply because I didn't receive any notifications and I just saw your reply when I check just now
I believe that’s because no actual currency was spent, or it’s a purchase within Studio.
oo then may I also know why the "UpdateLeaderBoard()" function in line 48 is not working? I tried to print("Updating Leaderboard..") when the function received the signal but it's not printing.
@Feahren hey man you there?
I’m not sure:/
Alright, thanks for your help anyway :)
You are gonna wanna use this for ze leaderboard https://developer.roblox.com/en-us/api-reference/class/OrderedDataStore