Heres my leaderboard module:
local lb = {};
local storedGlobal = {};
local storedGlobal2 = {}
local storedGlobal3 = {}
local storedPersons2 = {};
local storedPersons = {};
local storedPersons3 = {};
local DataStoreService = game:GetService("DataStoreService")
local wipeLeaderboards = 1
local RapSet = DataStoreService:GetOrderedDataStore('AloeV.' .. wipeLeaderboards .. ' _Rap')
local BuxSet = DataStoreService:GetOrderedDataStore('AloeV.' .. wipeLeaderboards .. '_Bux')
local NetSet = DataStoreService:GetOrderedDataStore('AloeV.' .. wipeLeaderboards .. '_Net')
local nextPossibleDelay = 1
GrabRap = function()
local globalData = {};
local page = RapSet:GetSortedAsync(false, 100);
page = page:GetCurrentPage();
for key, value in next, page do
globalData[#globalData + 1] = {value.key, value.value};
end
return globalData;
end
GrabBux = function()
local globalData = {};
local page = BuxSet:GetSortedAsync(false, 100);
page = page:GetCurrentPage();
for key, value in next, page do
globalData[#globalData + 1] = {value.key, value.value};
end
return globalData;
end
GrabNet = function()
local globalData = {};
local page = NetSet:GetSortedAsync(false, 100);
page = page:GetCurrentPage();
for key, value in next, page do
globalData[#globalData + 1] = {value.key, value.value};
end
return globalData;
end
addtitle = function(int)
if int <= 999 then
return tostring(int)
end
local new_number=tostring(int)
local place=#new_number
while place-3>0 do
place=place-3
new_number=string.sub(new_number,1,place)..","..string.sub(new_number,place-(-1))
end
return new_number;
end
function getMultiplier(amount)
local digits = #tostring(amount); -- gets the # of digits in number
if amount >= 92000000000000000000 then -- 9Qn (original cap)
local newNumber = digits * 10; -- multiplies it by 10 to make sure its always enough
return newNumber; -- returns the multipler
else
return 1; -- number smaller than normal cap - returns 1
end
end
function lb.UpdateAsync(statType, userId, newAmount)
newAmount = newAmount / getMultiplier(newAmount);
if statType == "RAP" then
RapSet:SetAsync(userId, newAmount);
elseif statType == "Bux" then
BuxSet:SetAsync(userId, newAmount);
elseif statType == "Net" then
NetSet:SetAsync(userId, newAmount)
end
end
function updateLeaders()
local s,m = pcall(function()
local topHundred = GrabRap()
for index = 1, 100 do
local data = topHundred[index];
local gui = storedGlobal[index];
if gui then
if data then
local key = data[1];
local value = data[2] * getMultiplier(data[2]);
local name, id = key:match("([%a%d_]+);(%d+)");
if id and name then
gui.Text = " " .. name .. " ";
gui.Number.Text = index..") ";
gui.Price.Text = addtitle(math.floor(value));
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
end
end
end)
if not s then
warn(m);
end
local s2,m2 = pcall(function()
local topHundred = GrabBux()
for index = 1, 100 do
local data = topHundred[index];
local gui = storedGlobal2[index];
if gui then
if data then
local key = data[1];
local value = data[2] * getMultiplier(data[2]);
local name, id = key:match("([%a%d_]+);(%d+)");
if id and name then
gui.Text = " " .. name .. " ";
gui.Number.Text = index..") ";
gui.Price.Text = addtitle(math.floor(value));
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
end
end
end)
if not s2 then
warn(m2);
end
local s3,m3 = pcall(function()
local topHundred = GrabNet()
for index = 1, 100 do
local data = topHundred[index];
local gui = storedGlobal3[index];
if gui then
if data then
local key = data[1];
local value = data[2] * getMultiplier(data[2]);
local name, id = key:match("([%a%d_]+);(%d+)");
if id and name then
gui.Text = " " .. name .. " ";
gui.Number.Text = index..") ";
gui.Price.Text = addtitle(math.floor(value));
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
else
gui.Text = "";
gui.Number.Text = index;
gui.Price.Text = "";
end
end
end
end)
if not s3 then
warn(m3);
end
end
function lb:Execute()
for index = 1, 100 do
local template = script.Leaderboard:clone();
template.Size = UDim2.new(0.375, -50, 0, 50);
template.Position = UDim2.new(0, 50, 0, 50 * (index - 1));
template.Parent = workspace.Bux.Leaderboard.Board.Canvas.People;
if index == 100 then
workspace.Bux.Leaderboard.Board.Canvas.CanvasSize = UDim2.new(0, 0, 0, template.AbsolutePosition.Y);
end
storedGlobal[#storedGlobal + 1] = template;
end
for index = 1, 100 do
local template = script.Leaderboard:clone();
template.Size = UDim2.new(0.375, -50, 0, 50);
template.Position = UDim2.new(0, 50, 0, 50 * (index - 1));
template.Parent = workspace.Rap.Leaderboard.Board.Canvas.People;
if index == 100 then
workspace.Rap.Leaderboard.Board.Canvas.CanvasSize = UDim2.new(0, 0, 0, template.AbsolutePosition.Y);
end
storedGlobal2[#storedGlobal2 + 1] = template;
end
for index = 1, 100 do
local template = script.Leaderboard:clone();
template.Size = UDim2.new(0.375, -50, 0, 50);
template.Position = UDim2.new(0, 50, 0, 50 * (index - 1));
template.Parent = workspace.Net.Leaderboard.Board.Canvas.People;
if index == 100 then
workspace.Net.Leaderboard.Board.Canvas.CanvasSize = UDim2.new(0, 0, 0, template.AbsolutePosition.Y);
end
storedGlobal3[#storedGlobal3 + 1] = template;
end
while task.wait(5) do
updateLeaders()
warn("LB Update Signal Fired")
end
end
return lb;
The leaderboard just isn’t updating - heres a picture of what they look like: