Skip to content

Instantly share code, notes, and snippets.

@RobertCodez
Last active July 30, 2021 16:42
Show Gist options
  • Save RobertCodez/d80dd1e23c22c1695b829f198397690c to your computer and use it in GitHub Desktop.
Save RobertCodez/d80dd1e23c22c1695b829f198397690c to your computer and use it in GitHub Desktop.
Global Leaderboard Script
local DatastoreService = game:GetService("DataStoreService")
local SlimeStore = DatastoreService:GetOrderedDataStore("SlimeStore")
local ResetTime = 60
while wait(1) do
ResetTime = ResetTime - 1
if ResetTime == 0 then
ResetTime = 60
for i, player in pairs(game.Players:GetPlayers()) do
SlimeStore:SetAsync(player.UserId, player.leaderstats.Slimes.Value)
end
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Frame" then
v:Destroy()
else
print(v.ClassName)
end
end
local success, errorM = pcall(function()
local Data = SlimeStore:GetSortedAsync(false, 50)
local Pages = Data:GetCurrentPage()
for rank,Storage in ipairs(Pages) do
local Username = game.Players:GetNameFromUserIdAsync(tonumber(Storage.key))
local Slimes = Storage.value
local Size = Enum.ThumbnailSize.Size420x420
local Type = Enum.ThumbnailType.HeadShot
local PFP, PFPready = game.Players:GetUserThumbnailAsync(Storage.key, Type, Size)
local Template = script.PlayerInfHolder:Clone()
Template.UserName.Text = Username
Template.Slimes.Text = Slimes
Template.PFP.Image = PFP
Template.Parent = script.Parent
end
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment