Explanation: So I'm made a top donator leaderboard and I am trying to save the data when a player donates robux but it was not successful as I tried to get the ErrorMessage if it didn't successfully save and the ErrorMessage says "Argument 2 missing or nil on line 46 & 59"
Here's the script:
-- Originally written by me, rewritten by @Feahren
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local RobuxDonationData = game:GetService("DataStoreService"):GetOrderedDataStore("DonationData")
local RobuxDonateEvent = ReplicatedStorage:WaitForChild("EventsFolder"):WaitForChild("RobuxDonateEvent")
local DataPageRequest = 15
local Leaderboard = workspace:WaitForChild("GlobalLeaderboard")
local BoardGUI = Leaderboard:WaitForChild("lbGUI")
local BoardSlots = BoardGUI:WaitForChild("Holder")
local function UpdateLeaderBoard()
print("Updating LeaderBoard...")
local Success, Response = pcall(RobuxDonationData.GetSortedAsync, RobuxDonationData, {false, DataPageRequest})
if (Success) then
print("Successfully Updated")
local RobuxDataPage = Response:GetCurrentPage()
for _, RobuxData in ipairs(RobuxDataPage) do
local Username = Players:GetNameFromUserIdAsync(tonumber(RobuxData.key))
print(Username)
local TotalDonated = RobuxData.value
local IsOnLeaderboard = false
for _, Slot in pairs(BoardSlots:GetChildren()) do
if (Slot.Player.Text == Username) then
IsOnLeaderboard = true
print("Player Is On LeaderBoard? "..IsOnLeaderboard.."!")
break
else
print("Player Is On LeaderBoard? "..IsOnLeaderboard.."!")
end
end
if (TotalDonated and not IsOnLeaderboard) then
local Slot = ServerStorage:WaitForChild("lbFrame"):Clone()
Slot.Player.Text = Username
Slot.Amount.Text = tostring(TotalDonated)
Slot.Position = UDim2.new(0, 0, (Slot.Position.Y.Scale + (0.08 * #BoardSlots:GetChildren())), 0)
Slot.Parent = BoardSlots
print("Slot Cloned")
end
end
else
error(Response) -- Error Here
end
end
local function ProcessReceipt(ReceiptInfo)
local Completed = Enum.ProductPurchaseDecision.PurchaseGranted
local NotProcessed = Enum.ProductPurchaseDecision.NotProcessedYet
local Player = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
if (Player) then
spawn(function()
repeat wait() until Completed
RobuxDonationData:IncrementAsync(ReceiptInfo.PlayerId, ReceiptInfo.CurrencySpent)
BoardSlots:ClearAllChildren()
UpdateLeaderBoard() -- Error Here
end)
return Completed
end
return NotProcessed
end
MarketPlaceService.ProcessReceipt = ProcessReceipt

12 comments
to be honest, it will be better if you print the response instead, because we don't actual know if it was an actual error or just the response that you get when it fails
try to printhm what do you mean? im confused
you are basically saying there's an error on the line where you create error() , change it to print so we can see if it was an error or just a failure
The thing here is that im using "pcall" here and "pcall" run functions without erroring. For the first argument, I wrote my desired function, which in this case, is if the data is successfully saved and the second argument, I wrote the "Response" which stands for the ErrorMessage. So whenever there's error, I can get the error message by writing error(Response) to get the error.
If I use the print function, the script will just print whatever is inside it if the data does not save successfully and I will not be able to know where did the script go wrong :/
Let’s just try getting rid of pcalling altogether to see where it really is having issues
what im saying is you are probably getting the errormessage at error(Response) instead of an actual error just change it to print(Response) dude is it so hard? we cant determine if it is an error or not if you make error() instead of print() bro are u sanity
https://pastebin.com/xCsjzEAB Run this for us
@Provement Bro clearly you don't understand what's error() for...Fine, I changed to this. "warn("An Error Occurred! \nError:", Response, "\nTrackBack:", debug.traceback())"
it warns me now, instead of "erroring" like you said :/
@Feahren HOLY what the dude, after removing the "else" part it works!
But why tho? can you post an answer explaining?