So, i'm trying to make a Client Sided Leaderboard, comparing Highest to Lowest ranked players based on their Values.
The Server Sided OnServerInvoke portion (this returns the Table that is nil on client side, but not nil on Server Side):
local UpdateVersion = script.Version.Value
local ClientRepLBData = game:GetService("DataStoreService"):GetOrderedDataStore("ClientRepLBDataV:"..UpdateVersion)
local ClientFunction = game.ReplicatedStorage.ClientLeaderboard
ClientFunction.OnServerInvoke = function()
local Success, Err = pcall(function()
local ClientLBData = ClientRepLBData:GetSortedAsync(false, 25)
local ClientLBPage = ClientLBData:GetCurrentPage()
local DataToSend = {}
for ClientLBRank, ClientLBData in ipairs(ClientLBPage) do
table.insert(DataToSend, {ClientLBRank, ClientLBData.key, ClientLBData.value})
end
wait()
return DataToSend
end)
if not Success then
error(Err)
end
end
This is the Client Sided portion, that would create the leaderboard based off the returned data (this prints nil):
if game:IsLoaded() then
local player = game.Players.LocalPlayer
local frame = script.Parent
local ui = frame.Parent
local lbframe = frame.RepLeaderboard
local RepStorage = game.ReplicatedStorage
local ClientLBEvent = RepStorage:WaitForChild('ClientLeaderboard')
while wait(45) do
for i,v in pairs(lbframe:GetChildren()) do
if v:IsA('Frame') then
v:Destroy()
end
end
wait()
local Data = ClientLBEvent:InvokeServer()
if Data ~= nil then
for i = 1, #Data do
local CopyFrame = frame.LBFrame.Frame:Clone()
if i == 1 then
CopyFrame.Rank.TextColor3 = Color3.fromRGB(255, 170, 0)
CopyFrame.Username.TextColor3 = Color3.fromRGB(255, 170, 0)
CopyFrame.Level.TextColor3 = Color3.fromRGB(255, 170, 0)
elseif i == 2 then
CopyFrame.Rank.TextColor3 = Color3.fromRGB(180, 180, 180)
CopyFrame.Username.TextColor3 = Color3.fromRGB(180, 180, 180)
CopyFrame.Level.TextColor3 = Color3.fromRGB(180, 180, 180)
elseif i == 3 then
CopyFrame.Rank.TextColor3 = Color3.fromRGB(210, 105, 30)
CopyFrame.Username.TextColor3 = Color3.fromRGB(210, 105, 30)
CopyFrame.Level.TextColor3 = Color3.fromRGB(210, 105, 30)
end
CopyFrame.Visible = true
CopyFrame.Name = tostring('Player'..Data[1])
CopyFrame.Rank.Text = Data[1]
CopyFrame.Username.Text = Data[2]
CopyFrame.Level.Text = Data[3]
CopyFrame.Parent = lbframe
CopyFrame.Position = UDim2.new(0, 0, CopyFrame.Position.Y.Scale + (0.032 * #lbframe:GetChildren()), 0)
end
else
print'data was nil'
end
end
end
If anyone could help, or provide some information that could lead me to the misunderstanding of this, it would be highly appreciated!

1 comment
NOTE: I JUST HAD A QUICK LOOK AT THIS SCRIPT!
Now, when using OnServerInvoke, the first argument will ALWAYS be the LocalPlayer. Leaving it empty can cause errors.
If this doesn't help, feel free to reply.