local dss = game:GetService("DataStoreService") local ds = dss:GetOrderedDataStore("DailyEggsData1.0") local resetTime = 30
local lbModel = script.Parent.Parent.Parent.Parent
local storedValueName = "DailyEggs"
local suffixes = {'','K','M','B','T','Qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'} local function format(val) for i=1, #suffixes do if tonumber(val) < 10^(i3) then return math.floor(val/((10^((i-1)3))/100))/(100)..suffixes[i] end end end
local cache = {} function getUserIdFromUsername(name) if cache[name] then return cache[name] end local player = game.Players:FindFirstChild(name) if player then cache[name] = player.UserId return player.UserId end local id local success, err = pcall(function() id = game.Players:GetUserIdFromNameAsync(name) end) cache[name] = id return id end
local characterAppearances = {}
function getCharacterApperance(userID) if characterAppearances[userID] then return characterAppearances[userID] end local humanoiddesc
local success, err = pcall(function() humanoiddesc = game.Players:GetHumanoidDescriptionFromUserId(userID) end) if not success then warn(err) while not success do local success, err = pcall(function() humanoiddesc = game.Players:GetHumanoidDescriptionFromUserId(userID) end) if success then break else wait(3) end end end characterAppearances[userID] = humanoiddesc return humanoiddesc
end
local function Handler() local Success, Err = pcall(function() local Data = ds:GetSortedAsync(false, 100) local Page = Data:GetCurrentPage()
local names = {} for Rank, Data in ipairs(Page) do local Name = Data.key local Amount = Data.value local NewObj = script.Template:Clone() NewObj.PlrName.Text = Name local retrievedValue = Data.value ~= 0 and (1.0000001 ^ Data.value) or 0 if Rank == 1 then NewObj.BG.BackgroundColor3 = Color3.fromRGB(216, 175, 13) elseif Rank == 2 then NewObj.BG.BackgroundColor3 = Color3.fromRGB(98, 98, 98) elseif Rank == 3 then NewObj.BG.BackgroundColor3 = Color3.fromRGB(165, 77, 0) end if game.Players:FindFirstChild(Name) then names[Name] = Rank end NewObj.Eggs.Text = format(math.round(retrievedValue)) NewObj.Rank.Text = "#"..Rank NewObj.Parent = script.Parent end end) if not Success then warn(Err) end
end
local timeUntilReset = resetTime
while wait(1) do timeUntilReset = timeUntilReset - 1 script.Parent.Parent.eeee.Text = "Resetting in ".. tostring(timeUntilReset).." Seconds" if timeUntilReset == 0 then
timeUntilReset = resetTime for _,Player in pairs(game.Players:GetPlayers()) do local storedValue = Player.Hidden[storedValueName].Value ~= 0 and math.floor(math.log(Player.Hidden[storedValueName].Value) / math.log(1.0000001)) or 0 ds:SetAsync(Player.Name, storedValue) end for _,v in pairs(script.Parent:GetChildren()) do if v:IsA("Frame") then v:Destroy() end end Handler() end
end
Handler()
game.Players.PlayerRemoving:Connect(function(Player) local storedValue = Player.Hidden[storedValueName].Value ~= 0 and math.floor(math.log(Player.Hidden[storedValueName].Value) / math.log(1.0000001)) or 0 local success, err = pcall(function() ds:SetAsync(Player.Name, storedValue) end) if success then print("leaderboard stats successfully saved") else local count = 0 while not success do local success, errormsg = pcall(function() ds:SetAsync(Player.Name, storedValue) end) count += 1 if success then print("Took ".. count .." to successfully save leaderboard stats") break else warn(errormsg) wait(3) end end end
end)